I have a fairly straightforward set of php forms that take users through a 3 step process before doing a final submit of their information.
I'm using session variables to retain the data across each page and also pull in each session variable to fields that may have already been submit so that the forms are 'sticky'.
The problem is that once they get to the 3rd part of the form, if they go backwards using the link provided, it errors because there has not actually been a POST of the data from the 1st section so there is nothing to set for the session variables.
To counter this i added the following piece of code for all my variables:
if(!isset($_SESSION['home_tel'])){
session_register('home_tel');
$_SESSION['home_tel'] = $_POST['home_tel'];
}
this worked fine until I realised that this means if a user goes back to the first page, it will not update the session to the latest data as its already set so thinks it doesn't have to do anything.
Is there an easy way to check the session values to see if they have changed before updating the session variable? Alternatively is there just a way to check if its been posted or not and if so then created the variable. I tried if(isset($_POST['home_tel'])).... etc but that doesn't seem to work.
Any help would be great??
Many thanks, Jonny