Hello there...
1) Firstly, why don't you put step1 and step2 together as html pages and process.php alone... that'd be better... and if you wanted to put process.php within step1+step2 then don't forget to write the following :
if ( isset($_POST["submit"]) )
{
/*
Insert our data to MySQL
*/
}
2) As for your problems, it seems that you have a problem with the variables because sometimes : "company" and "workphone" are not defined ( because of the choice of the radio form ) and you continue to insert them so a problem would be generated... the solution of this is :
if ( !empty($_POST["company"]) )
{
// Insert it...
}
and so on...
3) About making the fields - or some fields - required... is quite easy... all you have to do - with php if you want - is to include at the begining of the process page :
if ( empty($_POST["our-required-field"]) )
{
header("location: form.php?msg=This Field Is Required"):
// or
// echo "This Field Is Required";
}
please note that at the form.php page, u should write :
if ( isset($_GET["msg"]) )
{
echo $_GET["msg"];
}
but hey do you know some basics of Javascript ? if so, why don't you make the fields required with it ? this would definitely be faster and more dynamic... ex :
<script type="text/javascript">
function check()
elem = document.getElementById("required-field").value.length;
{
if ( elem == 0 )
{
alert("Missing Data In This Required Field!!");
elem.focus();
return;
}
}
</script>
<!-- consider the button below, a submit button of the form -->
<input type="text" name="required-field" id="required-field" />
<input type="button" name="submit" onclick="check()" />
4) finally, u are missing alot my friend... it is very dangerous to insert your POSTed data directly to your MySQL, due to SQL injections problems... i.e : it's wrong to insert the following :
<?php
$sql = "INSERT INTO tbl(name) VALUES ('$_POST[name]')";
?>
instead, the following should be done :
<?php
if ( get_magic_quotes_gpc() )
{
$name = htmlentities(mysql_real_escape_string(stripslashes($_POST["name"]), $dbconnection));
}
else
{
$name = htmlentities(mysql_real_escape_string($_POST["name"], $dbconnection));
}
// then :
$sql = "INSERT INTO tbl(name) VALUES ($name)";
?>
Good luck...