View Full Version : how to redirect to home page if not accessed sequentially
I have three php files, one.php, two.php, three.php
these three files need to be accessed in sequence. if one.php is submitted it displays two.php. if two.php is submitted, then three.php is displayed. if three.php is submitted then one.php will be displayed. alternately, these three files can be accessed individually. like in the address bar user can type localhost:8080/one.php, localhost:8080/two.php or localhost:8080/three.php. when accessed individually, user should be redirected to one.php because two.php and three.php are getting some values from one.php and error is getting displayed when the later action is performed. How can I achieve this.
09-04-2007, 04:56 PM
Add this as your first set of lines
I added the above code to three.php because this three.php should come after "two.php". when I tried to access three.php directly it is directing me to one.php which is good. but when I am navigating from one.php then two.php then three.php. here I am expecting that three.php should get displayed. but here also it is redirecting to one.php . Where am I doing the mistake? Thanks in advance for the help.
09-04-2007, 08:03 PM
$_SERVER['HTTP_REFERER'] is not reliable. Note: The actual name is spelled - 'HTTP_REFERER'. This is spelled incorrectly in the above posts (always turn on full php error reporting when learning, developing, and debugging code. This spelling error would have been pointing out through the use of php error reporting.)
It depends on which browser is being used, the version, and if the visitor has disabled sending the REFERER in his browser. Also, a script can set it to your page2 value and keep submitting to your page3 code, without actually needing to visit the other pages first...
I recommend using a session variable to track which page a visitor came from.
how can I use a session variable. any clue would help me.
09-07-2007, 08:11 PM
Start a session on page1 and unconditionally create a session variable with a value of 1 in it.
One all the other pages, resume/start a session. If the session does not contain a session variable with the proper value that says the visitor came from the proceeding page, redirect back to page1. Either they got to the current page directly (the session variable won't exit at all) or they got to the current page out of order.
If the session variable exists with the correct value for the proceeding page, they got to the current page correctly. Set the session variable to the proper value for the current page.
Powered by vBulletin® Version 4.2.2 Copyright © 2015 vBulletin Solutions, Inc. All rights reserved.