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=\"{$_SER VER['PHP_SELF']}\" method=\"POST\" >
<table width=\"700\" border=\"0\" cellpadding=\"0 \" align=\"center\ ">
<tr>
<td colspan=\"34\"> <div align=\"center\ "><strong>SURVE Y
</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?
&nb sp;
<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=\"Continu e\"/></td>
</tr>
</table>
</form>";
}
else {
include('nextpa ge.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.)
<?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=\"{$_SER VER['PHP_SELF']}\" method=\"POST\" >
<table width=\"700\" border=\"0\" cellpadding=\"0 \" align=\"center\ ">
<tr>
<td colspan=\"34\"> <div align=\"center\ "><strong>SURVE Y
</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?
&nb sp;
<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=\"Continu e\"/></td>
</tr>
</table>
</form>";
}
else {
include('nextpa ge.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.)
Comment