karenn1 Posted May 14, 2008 Share Posted May 14, 2008 Hey everyone, I have a website where you can place an order to send a package to London. My pages are setup as parcels1.php, parcels2.php. etc. There are 7 steps to follow (address, package size, payment, etc) when sending a parcel. How can I prevent someone from just typing in www.mysite.com/parcels3.php to skip steps? Because Step 1 creates the Session ID, I need the user to move linear from 1 through to 7. How can I do this with PHP? Thanks! Karen Link to comment https://forums.phpfreaks.com/topic/105576-solved-page-access-preventing-non-linear-action/ Share on other sites More sharing options...
conker87 Posted May 14, 2008 Share Posted May 14, 2008 You could have a session value (perhaps $_SESSION['at_page']) and make it the value of the previous page. Then check this value after validating from the previous page. Link to comment https://forums.phpfreaks.com/topic/105576-solved-page-access-preventing-non-linear-action/#findComment-540823 Share on other sites More sharing options...
karenn1 Posted May 14, 2008 Author Share Posted May 14, 2008 Thanks for your reply, conker87. How do I implement this? What would the coding look like for each page? Thanks! Karen Link to comment https://forums.phpfreaks.com/topic/105576-solved-page-access-preventing-non-linear-action/#findComment-540847 Share on other sites More sharing options...
conker87 Posted May 14, 2008 Share Posted May 14, 2008 For instance, at the bottom of the first page: page1.php // After you've validated your values and everything is fine to continue: $_SESSION['at_page'] = 2; -- page2.php if ($_SESSION['at_page'] == 2) { //do your page2 stuff // after everything is validated again, and you're ready to continue $_SESSION['at_page'] = 3; } else { echo "Please start at page one"; } etc etc Link to comment https://forums.phpfreaks.com/topic/105576-solved-page-access-preventing-non-linear-action/#findComment-540850 Share on other sites More sharing options...
karenn1 Posted May 14, 2008 Author Share Posted May 14, 2008 conker87, you are a star! Works like a dream! I only changed the echo to this: "exit(header("Location:http://www.mysite.com/parcels1.php"));" to send people to the right page. Thanks again! Karen Link to comment https://forums.phpfreaks.com/topic/105576-solved-page-access-preventing-non-linear-action/#findComment-540863 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.