<b>How do I put the form in the same script? Do I just make a copy of the .htm file, rename it to .php, and insert the validation somewhere inside?</b>
<i>Richard A. Rijnders wrote:
Well, putting all the validation on the same page eliminates the problem of your original post. Putting the form, itself, in the same script or in an <b>include()</b>ed file will also simplify your coding.</i>
<b>Not sure I follow. What else do I need to perform validation? Do I need some more lines after or before this?</b>
<i>Richard A. Rijnders wrote:
The validations are straight forward. The logic will be:
<?PHP
$form_errors = validate_fields();
if(!$form_errors) {
// process form
process_form();
header("Location: nextpage.php");
}
else {
//redisplay form with errors
include("form.inc");
print $form_errors;
}
?></i>
<b>Were do I insert this line -- in the .php or .htm file? Does it need to be enclosed with <i><?php</i> & <i>?></i>? And each value ($name, $email, $phone, etc., etc.) needs a similar line, correct?</b>
<i>Richard A. Rijnders wrote:
I think you are only going to get stuck trying to redisplay the form with errors <i>and</i> their original values. The trick is to use the <b>VALUE</b> attribute of the form field tags, like so:
print "<INPUT TYPE='TEXT' NAME='myTextField' VALUE='" . $myTextField . "'>";
This will repopulate the form field with the value that was previously submitted.</i>