Forum Moderators: coopster
I want there to be a "confirmation page" so that users can double check the responses before submitting them to the database. This would combat duplicate entries caused by misspellings and user error. Anyone have any ideas how to do this? Below is example code from my files:
--- HTML Code ---
<html>
<head>
<title>Report</title>
</head>
<form action="input.php" method="post">
<h1 align="center"> Report Form</h1><br /><br />
<b>Site:</b>
<form>
<select name="sites">
<option value="First">1st Street </option>
<option value="Baltimore">Baltimore</option>
<option value="UnionStation">Union Station</option>
</select><br />
<b>Department:</b>
<form>
<select name="dept">
<option value="Front">Front Office</option>
<option value="Acct">Accounting</option>
<option value="Corporate">Corporate</option>
</select><br />
<b>Location of Incident:</b>
<form> <input type="text" name="location">
</select><br />
<input type="submit" value="Submit" />
<input type="reset" value="Clear Form" />
</form>
</div>
</body>
</html>
--- PHP File ---
<?php
echo '<br />';
echo 'Site: <b>'.$_POST['sites'].'</b><br />';
echo 'Department: <b>'.$_POST['dept'].'</b><br />';
echo 'Location of wreck: <b>' .$_POST['location'].'</b><br />';?>
IE: <input type="hidden" name="dept" value="<? echo $_POST['dept']?>">
The "submit" button could say "Confirm" or whatever. Then that form would when posted actually writes the data to your DB.
The other option, which I would prefer, would be to display a Yes/No JavaScript dialog that displays the form values and then posts the form if the person clicks "Yes".
[edited by: phpmaven at 6:19 pm (utc) on Jan. 3, 2007]
EDIT:
So, are you saying I would put <input type="hidden" name="dept" value="<? echo $_POST['dept']?>"> into the input.php file? Would the input.php file now be:
<?php
echo '<br />';
echo 'Site: <b>'.$_POST['sites'].'</b><br />';
echo 'Department: <b>'.$_POST['dept'].'</b><br />';
echo 'Location of wreck: <b>' .$_POST['location'].'</b><br />';
<input type="hidden" name="dept" value="<? echo $_POST['dept']?>">
<input type="submit" value="Submit" />
?>
[edited by: MC_SAS_Master at 6:25 pm (utc) on Jan. 3, 2007]
For Example:
input type="hidden" name="sites" value="<? echo $_POST['sites']?>"
input type="hidden" name="dept" value="<? echo $_POST['dept']?>"
input type="hidden" name="location" value="<? echo $_POST['location']?>"
That form would then post to your "input.php" script. In fact, if you followed my example above, you shouldn't have to change anything in your "input.php" script.
<?php
echo '<br />';
echo 'Site: <b>'.$_POST['sites'].'</b><br />';
echo 'Department: <b>'.$_POST['dept'].'</b><br />';
echo 'Location of wreck: <b>' .$_POST['location'].'</b><br />';
?>
<input type="hidden" name="dept" value="<? echo $_POST['dept']?>">
<input type="submit" value="Confirm" />
Unfortunately, when hit the "Confirm" button nothing happens. Any idea as to what I'm doing wrong?
Once the PHP is processed (validated) then the html will pick up. Html will not show until PHP is processed.
Check your form tags.