Posted by Jerim79 on 04/06/07 18:16
Here is my form:
<?php
$Number;
$Email;
$error=0;
if (empty($Number)){
$msg1="* You did not enter the number of people in your
household.";
$error++;
}
if (empty($Email)){
$msg2="* You did not enter your email address.";
$error++;
}
if ($error>0){
echo "<form action=\"{$_SERVER['PHP_SELF']}\" method=\"POST\">
<table width=\"700\" border=\"0\" cellpadding=\"0\" align=\"center\">
<tr>
<td colspan=\"34\"><div align=\"center\"><strong>SURVEY
</strong></div></td>
</tr>
<tr>
<td colspan=\"34\" bordercolor=\"#ECE9D8\" height=\"5\" align=\"center
\" > <hr/> <br/> <
</td>
</tr>
<tr>
<td colspan=\"34\">How many people are in your household?
<input type=\"text\" name=\"Number\" width=\"40\" />$msg1</td>
</tr>
<tr>
<td colspan=\"34\" align=\"center\"><br/></td></tr>
<tr>
<td align=\"right\" colspan=\"15\">Please Enter Your Email
Address: </td>"
<td width=\"480\" colspan=\"24\"><input type=\"text\" name=\"Email\"
value=\"\" width=\"200\">$msg2</td>
</tr>
<tr>
<td colspan=\"34\"> </td>
</tr>
<tr>
<td colspan=\"34\" align=\"center\"><input name=\"Submit\" type=
\"SUBMIT\" value=\"Continue\"/></td>
</tr>
</table>
</form>";
}
else {
include('nextpage.php');
}
?>
This works fine in that it catches what it needs to catch. However,
obviously, it prints out the error message upon first loading the
page. I would like to wait until after the user has clicked Submit and
the form has been posted, before it prints the error message to the
screen. Or is there a better way to do this? (I have done the separate
form for verification method before. I am trying to see if there is a
way to verify the form from within itself.)
[Back to original message]
|