Forum Moderators: coopster
Do something like this:
if($_POST['form_submit'])
{
echo "Thank you for entering your data!<br><br>";
echo "Your first name: $_POST['fname']<br>";
echo "Your last name: $_POST['lname']<br>";
}
else {
echo "<form action=$_SERVER['PHP_SELF'] method='post'>\n
First Name<input type='text' name='fname' size=40><br>\n
Last Name <input type='text' name='lname' size=40><br>\n
<input type='hidden' name='submit_form' value=1>\n
<input type='submit' value='Register!'>\n
</form>";
}
hope this helps
Do something like this:
session_start();
if($_POST['form_submit'])
{
echo "Thank you for entering your data!<br><br>";
echo "Your first name: $_POST['fname']<br>";
echo "Your last name: $_POST['lname']<br><br>";
echo "Is this information correct?<br>";
//links to make it simpler
echo "<a href='form.php?add=0'>NO</a>";
echo "<a href='form.php?add=1'>YES</a>";
$_SESSION[fname] = $_POST[fname];
$_SESSION[lname] = $_POST[lname];
}
else if($_GET[add] == 1) { //Here is obviously a security issue but its for demostration purposes
//code to add info to database but use the session variables
unset($_SESSION[fname]);
unset($_SESSION[lname]);
session_destroy();
}
else {
unset($_SESSION[fname]);
unset($_SESSION[lname]);
session_destroy();
echo "<form action=form.php method='post'>\n
First Name<input type='text' name='fname' size=40><br>\n
Last Name <input type='text' name='lname' size=40><br>\n
<input type='hidden' name='submit_form' value=1>\n
<input type='submit' value='Register!'>\n
</form>";
}
There are some issues with security here but i just wanted to show you. Im really tired so you might have to check the code for errors...then again the whole thing could be an error.
Hope this helps...im going back to sleep
eelix
hope this helps
Actually as i have it now, its both a form and a thank you page. If you want to split the code into two pages, this is how it could look:
form.html
<form action=thank_you.php method='post'>
First Name<input type='text' name='fname' size=40><br>
Last Name <input type='text' name='lname' size=40><br>
<input type='hidden' name='submit_form' value=1>
<input type='submit' value='Register!'>
</form>
thank_you.php
<?php
session_start();if($_POST['form_submit'])
{
echo "Thank you for entering your data!<br><br>";
echo "Your first name: $_POST['fname']<br>";
echo "Your last name: $_POST['lname']<br><br>";
echo "Is this information correct?<br>";//links to make it simpler
echo "<a href='form.php?add=0'>NO</a>";
echo "<a href='form.php?add=1'>YES</a>";$_SESSION[fname] = $_POST[fname];
$_SESSION[lname] = $_POST[lname];}
else if($_GET[add] == 1) { //Here is obviously an issue but its for demostration purposes//Code to use information after it has been verified...
unset($_SESSION[fname]);
unset($_SESSION[lname]);
session_destroy();
}
else {
unset($_SESSION[fname]);
unset($_SESSION[lname]);
session_destroy();echo "<form action=form.php method='post'>\n
First Name<input type='text' name='fname' size=40><br>\n
Last Name <input type='text' name='lname' size=40><br>\n
<input type='hidden' name='submit_form' value=1>\n
<input type='submit' value='Register!'>\n
</form>";
}
?>
Something like this...Hope this helps
eelix
if($_POST["formsent"] == "formsent")
and
// redirect to the thank you page
header("Location: [website...] address.com/enquiry-thanks");
The helps appreciated.
Dexie.