Hi
I have a basic php script over 3 pages based on sending input through a form, saving the posted data as session variables and redirecting the user to a new page.
I cannot get the session variables to be displayed on the last page though!
I usually wouldn’t be doing a redirect with a simple form submission and just going from page 1 - page 3 but on this occasion i have been told this process needs to be kept.
My code and structure is below:
Page 1:
<?php
session_start();
?>
<form name="search-form" action="page2.php" method="post">
<input type="text" name="forename" />
<input type="text" name="surname" />
<input type="submit" value="SUBMIT" />
Page 2:
<?php
$_SESSION['forename'] = $_POST['forename'];
$_SESSION['surname'] = $_POST['surname'];
header('Location: http://xxxxxxxxx/page3.php');
?>
Page 3:
<?php
echo "
".$_SESSION['forename']."
".$_SESSION['surname']."
";
?>
Any help very much appreciated! This is the first time i am using the redirect ‘location’ function so i can only think it has to do with this, have used session variables before without struggling too much (i thought!!)
thanks