Click to See Complete Forum and Search --> : input type button tracking (PHP)


tripwater
04-16-2003, 07:49 PM
Hello I have a site that tracks the users steps through a setup process (I am using PHP on the server side). I am displaying which step they are on via images and some pages get skipped if certain conditions are met and others are included. I have this working fine.

My problem is I know that at sometime the user might make a mistake and click back (BTW I have opened a new window for this and got rid of the browser menu so I have control) so I have a <input type=button onclick= history.back();> So I want to use this button to signal the page it goes back to.

What I need to know is how do I check on the page that I go to from the back button that I got there from that button?

I have a sess_var called "step" that I increment on each page that tells me what step I am on and I would like to be able to say if the back button was pressed then decrement the sess_var "step" so the images will be correct. I hope I have explained myself well. Basically if there is a id= or name= that will give me a flag via post_vars or another method that would give me what I need to trigger my if (back pressed) conditional.

Thank you ahead of time for any help.

pyro
04-16-2003, 10:07 PM
Why not just pass the step the user is currently on via the query string? This way, you will always know what page they are on, no matter if the back up, go forward, etc...

tripwater
04-17-2003, 08:53 AM
Could you please explain what you mean by query string?

pyro
04-17-2003, 08:57 AM
What I mean is forward them to the next page, but send a query string along with it. For example, when the first for is submitted, and you go to send them to the next page, go page2.php?page=2. An alternative to this would be to just name your pages in such a way (ie. page1.php, page2.php) so you can tell what step they are on by the page number.

tripwater
04-17-2003, 09:09 AM
I understand the query string I have used it before. I just did not know it was called that. Sorry for the newbie here but I am used to using that in a link or clickable image. how does that work with the javascript history.back()?


See My problem is my pages are not sequencial. They need to appear that way to the user but if they have been to the site before then certain pages are skipped or if their billing address is same as their contact info then I include another page that skips the billing info page. By doing this the steps are off.

So my solution was to set a sess var and increment it on every page but if a back button was clicked then I just check for it on each page and decrement the sess var and have a block of conditionals on each page that checks for what image to show for that step.

Is this a stupid or possible solution? I just thought if I could test for that input type button being pressed all I would do is decrement and no matter what my steps would me correct.

So the numbering of pages I don't think will work for me in this situation. Again Thank you for help help in this matter if you see something wrong with my logic or have a better way let me know I think I did a bad job describing what I am trying to accomplish the first time.

tripwater
04-17-2003, 09:15 AM
Being that I am calling the Javascript to pull a back on the page history is that a cached page or a rloaded one? because if the page is cached then my sess var is no good anyway being that it never hit the server again ....correct?

tripwater
04-17-2003, 09:24 AM
I tested it and the sess var is incrementing on the page from coming back . I am still learning here. Bare with me. I thought for a second that because this is a server side language that if this is a cached page the sess var might not act right upon entering the same page but the code just increments as you enter. So it did its job. Now if I can check for the back and decrement I will be set.

pyro
04-17-2003, 11:34 AM
Unfortunatly, you can't check for the if the browser's back button was hit. I'm still not really clear on what you are trying to do, so I don't know how to lead you...