In my PHP form structure
page 1 : has form
page 2 : executes conditional redirections (to page 1 or to page 3)
page 3 : record form into DB, inform the visitor about successful operation and thank to the visitor
sample simplified code
page 1
html form (action is POST to page 2)
page 2
if ( session variable value is 'success' )
{ redirect to homepage;
die; }
if form is not correctly filled redirect to page 1
if form is correctly filled redirect to page 3
page 3
insert form into MySQL database;
echo 'thanks visitor, your comments has been added';
set session variable to 'success';
note: BACK button below means the browser's back button (not a custom link)
if I hit BACK button on page 3 after successfull form submission ( page orders page 1 -> page 2 -> page3 ) I observed that browser (Chrome for the time being) page goes to page 1. ( so after hittng back button the page order is page 3 -> page 1 )
I couldn't achieve page 3 -> page 2 -> some page (I am 99.9% sure that my codes for this trials are correct and valid for the purpose)
So I ask that what is the behaviour of BACK button in this situation? Why my PHP codes were not read by the server and applied by the browser (I mean PHP codes of page 2. Because order was page 2 -> page 3 so by hitting back, I normally expect codes of page 2 is to be read again)
What I exactly can not understand is
- I set session variable to 'success' in page 3.
- I say in page 2 that if session variable is 'success' then go to homepage
- page 2 is the just previous page of page 3
So why I can't arrive to homepage after hitting back button while I am on page 3?