I have two pages page one and page_two, in page_one the user enter some information which will be inserted in the database and when the he press enter he should be directed to page_two and inside this page there are the same information that he entered in page_one. and the problem is every time the user refresh page_two the data is inserted in the database again. I tried to fix this issue by using header to a new page, it worked but in page_two the information that was entered in page_one is lost.
page_one
<form action="page_one.php" method="post" name="info" >
<input name="userName" type="text" />
<input name="userEmail" type="text" />
<input name="userPass" type="text" />
<input name="submit" type="submit" />
</form>
<?php
include('db.php');
if(isset($_POST['Login']))
{
$user_name = $_POST['userName'];
$user_email = $_POST['userEmail'];
$password = $_POST['userPass'];
mysql_query("INSERT INTO users VALUES ('$user_name',' $user_email',' $password')");
header("Location:page_two.php.php");
exit;
}
?>
page_two
<?php
$user_name = $_POST['userName'];
$user_email = $_POST['userEmail'];
$password = $_POST['userPass'];
echo 'your user name: '.$user_name;
echo 'your email: '.$user_email;
echo 'your password: '.$password;
<input name="userName" type="hidden" value="<?php echo $user_name; ?>" />
<input name="userEmail" type="hidden" value="<?php echo$user_email; ?>" />
<input name="userPass" type="hidden" value="<?php echo $password; ?>" />
when I try this code it gives me this error message from page_two:
notice undefined index userName
notice undefined index userEmail
notice undefined index userPass