Code: Select all
TOP OF PAGE
<?php
$first_run = (isset($_POST["$first_run"])) ? $first_run += 1 : 0;
?>
<-- in between code not necessary for help -->
middle code
<table>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<tr><td>Email : </td><td>
<input tabindex="0" type="text" name="user_email" /></td></tr>
<tr><td>Name : </td><td>
<input type="text" name="user_name" /></td></tr>
<tr><td>Company(optional) :</td><td>
<input type="text" name="user_company" /></td></tr>
<tr><td>Phone Number : </td><td>
<input type="text" name="user_phone" /></td></tr>
<tr><td>Additional Information :</td>
<td>
<textarea cols="40" rows="10" name="user_message"> </textarea>
</td></tr>
<tr><td>
<input type="hidden" name="first_run" value="<?php echo $first_run; ?>">
<input align="middle" type="submit" value="confirm" />
</td></tr>
</form>
</table>
<?php
if ($first_run > 0 ) {
$email = $_POST['user_email'];
$name = $_POST['user_name'];
$company = $_POST['user_company'];
$phone = $_POST['user_phone'];
$message = $_POST['user_message'];
echo "Your email is : ' $email '<br />";
echo "Your name is : ' $name '<br />";
echo "Your company is : ' $company '<br />";
echo "Your phone number is : ' $phone '<br />";
echo "Your message is : ' <br /><br />$message<br /><br />";
echo "If the information above is correct please click send.";
echo "<form method=\"post\" action=\"sent.php\">";
echo "<input type=\"submit\" value=\"send\" align=\"middle\" />";
echo "</form>";
print("<br /><br /><br /><p>Click send if the above information is correct.</p>");
echo "<form method=\"post\" action=\"sent.php\">";
echo "<input type=\"submit\" value=\"send email\" name=\"send\">";
echo "</form>";
}
else {
/* the page has loaded for first time run so nothing is shown until user clicks confirm */
}
?>So basically I would like at the first run time of the page that only the table be shown and the confirm button be visible. Then when they click confirm my understand is that PHP_SELF will reload the page causing the conditional ' $first_run = (isset($_POST["$first_run"])) ? $first_run += 1 : 0; ' to increment $first_run + 1 so that my php at the bottom of the page the conditional ' if $first_run > 0 ' will become true so the user can verify that the information they submitted is correct and then the user will be able to click send. Send will call send.php which just uses the mail function and displays that the information has been sent.
When running this code the bottom php never becomes visible after i hit confirm. Can someone just explain the best route to take for mixing in error checking and showing html based on what "stage" the user is at on the page. Maybe a link to a tutorial? Thanks for help!