Here is a simplified version of a script which I named register.php that processes user input from a registration form.[php]
<?php if (isset($_POST['submitted'])) { $firstname = mysql_real_escape_string($_POST['firstname']); $lastname = mysql_real_escape_string($_POST['lastname']); header("Location: register_confirm_page.php?firstname=$firstname&lastname=$lastname"); } ?>[/php]As intended, the firstname and lastname posted variables are carried over to a redirected page register_confirm_page.php where the user is supposed to review his registration details before clicking the final submit button to be registered. Below is a simplified version of the register confirm page:
So far everything works just fine as intended.[php]
" ; echo "Lastname:" .$lastname //Show the submit button. echo' '; ?>[/php]
Now the intent is to send the first name and last name to yet another page register_confirm.php, where the value is finally submitted into my database. To keep it simple, I won’t include this third page, but what I basically did there was use the GET method as above, to retrieve the values again. Well this time around, the first and last names are not sent to the third page. Instead, the literal values ‘$firstname’ and ‘$lastname’ are passed through the url to the third page and I know this because that’s what shows up in the url when I click the submit button and that’s also what shows up in my database table. Does anyone understand why this may be happening and not what I expected would happen? I have passed variables between more than 2 pages before but this is the first time I am encountering this problem. I really can’t see what is being done wrong here. Perhaps someone can.