BAsically, what you do is echo out all the values they have filled out.
So in the recieving page,m yopu process all the information. If you miss any, you spit out the original form, and place submitted values in the form.
The alternative is using javascript functions to test the input ion the form. The downside to this is that not all users have javascript enabled, which will through them some errors.
To give you an example, I have included a section of one of the forms I include in my pages:
</td></tr><tr>
<td class=formlabel>* Initials </td><td class=formel><input class=\"formel_1\" type=\"text\" value =\"$initials\" name=\"initials\"></td></tr><tr>
<td class=formlabel>* First name </td><td class=formel><input class=\"formel_1\" type=\"text\" value =\"$name\" name=\"name\"></td></tr><tr>
<td class=formlabel>* Family name </td><td class=formel><input class=\"formel_1\" type=\"text\" value =\"$fname\" name=\"fname\"></td></tr><tr>
<td class=formlabel>* Gender </td><td class=formel><input class=\"formel_1\" type=\"radio\" name=\"gender\" $formm value=\"M\"> Male <input class=\"formel_1\" $formf type=\"radio\" name=\"gender\" value=\"F\"> Female</td></tr><tr>
<td class=formlabel>Organisation / institute </td><td class=formel><input class=\"formel_1\" value =\"$organisation\" type=\"text\" name=\"organisation\"></td></tr><tr>
<td class=formlabel>Department </td><td class=formel><input class=\"formel_1\" type=\"text\" value =\"$department\" name=\"department\"></td></tr><tr>
<td class=formlabel>Address </td><td class=formel><input class=\"formel_1\" type=\"text\" value =\"$address\" name=\"address\"></td></tr><tr>
<td class=formlabel>Postal City Code</td><td class=formel><input class=\"formel_1\" type=\"text\" value =\"$postal\" name=\"postal\"></td></tr><tr>
<td class=formlabel>* City </td><td class=formel><input class=\"formel_1\" type=\"text\" value =\"$city\" name=\"city\"></td></tr><tr>
<td class=formlabel>State </td><td class=formel><input class=\"formel_1\" type=\"text\" value =\"$state\" name=\"state\"></td></tr><tr>
<td class=formlabel>Zip-Code </td><td class=formel><input class=\"formel_1\" type=\"text\" value =\"$zipcode\" name=\"zipcode\"></td></tr><tr>
<td class=formlabel>* Country </td>
<td class=formel>
<select class=\"formel_1\" name=\"country\">
<option value = \"\">Select Country</option>
$countrylist
</select>
</td></tr><tr>
<td class=formlabel>Phone </td><td class=formel><input class=\"formel_1\" value =\"$phone\" type=\"text\" name=\"phone\"></td></tr><tr>
<td class=formlabel>Fax </td><td class=formel><input class=\"formel_1\" value =\"$fax\" type=\"text\" name=\"fax\"></td></tr><tr>
<td class=formlabel>* E-mail address </td><td class=formel><input class=\"formel_1\" value =\"$email\" type=\"text\" name=\"email\"></td>
</tr></table>
<p class=\"regkop\">2. Delegate category</p>
These are the final fees.
<p>The fee for two day Staff/PhD-Student participants includes the fee for the Symposium Dinner on Thursday evening.
<BR>One-day Staff/PhD-Student participants and Companions, who like to join the Symposium Dinner on Thursday evening
can indicate this at point 10.
<BR>The fee for one-day Staff/PhD-Student participants includes coffea/tea plus lunch.
<BR><BR>Nederlandse studenten hebben gratis toegang: zonder lunchgebruik. Registreren wel verplicht. Betaling kan achterwege blijven.
</p>
<table class=\"formtable\">
<tr>
<td class=formlabel>Delegate category<p></p>
</td><td class=formel2>Price p.p.
</td>
</tr><tr>
<td class=formlabel2><input class=\"formel_1\" onClick=\"updateprice()\" type=\"radio\" $cat1 name=\"category\" value=\"1\">
Staff two day att.
</td><td class=formel2 id=cat1>$kcat1
</td>
</tr><tr>
<td class=formlabel2><input class=\"formel_1\" onClick=\"updateprice()\" type=\"radio\" $cat2 name=\"category\" value=\"2\">
Staff one-day att.
</td><td class=formel2 id=cat2>$kcat2
</td>
</tr><tr>
<td class=formlabel2><input class=\"formel_1\" onClick=\"updateprice()\" type=\"radio\" $cat3 name=\"category\" value=\"3\">
PhD-Student two-day att
</td><td class=formel2 id=cat3>$kcat3
</td>
I do some basic processing:
if($gender == "M") {$formm = "checked";} else {$formf = "checked";}
if($category == 2 ) {$cat2 = "checked"; $cat1 = "";} elseif($category == 3) {$cat3 = "checked"; $cat1 = "";} elseif($category == 4) {$cat4 = "checked"; $cat1 = "";} else {$cat1 = "checked";}
if($student == 1) {$stud = "checked";}
if($arrival == '20040413') {$arr1 = "checked";} elseif($arrival == '20040414') {$arr2 = "checked";} elseif($arrival == '20040415') {$arr3 = "checked";} elseif($arrival == '20040416') {$arr4 = "checked";} elseif($arrival == '20040417') {$arr5 = "checked";} else {$arr2 = "selected";}
if($departure == '20040413') {$darr1 = "checked";} elseif($departure == '20040414') {$darr2 = "checked";} elseif($departure == '20040415') {$darr3 = "checked";} elseif($departure == '20040416') {$darr4 = "checked";} elseif($departure == '20040417') {$darr5 = "checked";} else {$darr4 = "selected";}
if($oneday == 1) {$oned = "checked";}
if($excursion == 1) {$exc = "checked";}
if($oral == 1) {$or = "checked";}
if($poster == 1) {$post = "checked";}
and test whether the form has been filled out:
if($nights < 0) {$errors .= "You cannot leave before you arrive<br>";}
if(empty($initials)) {$errors .= "You have to fill out your initials<br>";}
if(empty($name)) {$errors .= "You have to fill out your name<br>";}
if(empty($fname)) {$errors .= "You have to fill out your name<br>";}
if(empty($gender)) {$errors .= "You have to fill out your gender<br>";}
if(empty($city)) {$errors .= "You have to fill out your city<br>";}
if(empty($country)) {$errors .= "You have to fill out your country<br>";}
and test for errors:
if(isset($_POST[formid])) // Form was submitted
{
if(empty($errors)) // Input is OK
{
if(! isset($_SESSION[name])) // User is not logged in: No update of data
{
} // end of no errors
else
{
$body = "<b>The following errors occurred when processing your form:</b><br><hr>".$errors."<hr>Please close this window, correct the mistakes, and submit again";
include("../includes/updateform.php");
}
Hope this helps,
J.