Variables lost while going back

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
K-Z
Forum Commoner
Posts: 29
Joined: Mon Jul 05, 2010 9:03 am

Variables lost while going back

Post by K-Z »

Hi....I am developing a website and I am stuck in a weird problem. I am passing php variables from 1 php page (say x) to another php page (say y) with the help of $_POST[]. Page y makes use of the passed variable without which all of its contents are not displayed. Now, if I move on to any other page from page y and then I go back to page y, then the error Confirm Form Resubmission comes. What I am able to understand is that the problem is because of the absence of the variable that was passed from page x to page y. That is, $_POST[] is not able to get any variable or value.

Now, if I am correct, can you please tell how to cope up the loss of variables whenever a user tends to go back. One way which I have released is usage of cookies but I dont find it very suitable or preferred way. And if I am wrong, what can be reason of the error??

Please help me...
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Variables lost while going back

Post by JakeJ »

You need to use sessions. There are many tutorials available. It's pretty simple but there are a few things you have to watch out for.

You can turn your post variables in to session variables so they are then available from any page in the same session.
K-Z
Forum Commoner
Posts: 29
Joined: Mon Jul 05, 2010 9:03 am

Re: Variables lost while going back

Post by K-Z »

JakeJ wrote:You need to use sessions. There are many tutorials available. It's pretty simple but there are a few things you have to watch out for.

You can turn your post variables in to session variables so they are then available from any page in the same session.
Thnks jake....Thts a good sol...
Post Reply