tqla Posted July 7, 2007 Share Posted July 7, 2007 Hi. I have a survey that spans 3 pages. I want to make it impossible to go to page 2 and 3 by protecting them (ie: if someone goes to page 2 or 3 without going to page 1 first they will be sent to page 1.) This sounds a lot like a user authentication system but it's not really. I don't require them to log in. They just need to start the survey from the beginning on page 1. How do you do this? Thanks! Link to comment https://forums.phpfreaks.com/topic/58798-solved-protecting-pages-help/ Share on other sites More sharing options...
pocobueno1388 Posted July 7, 2007 Share Posted July 7, 2007 On page one, you can have a hidden input type named "page1_complete", then on the second page, just check if that variable exists, if it doesn't....redirect them to page 1. <?php if (!isset($_POST['page1_complete'])){ header('Location: page1.php'); } else { //show page 2 } ?> Then on page 2, have a hidden input called "page2_complete". And of course, on page 3 check if that variable exists, if it doesn't....redirect them to page 1 again. Link to comment https://forums.phpfreaks.com/topic/58798-solved-protecting-pages-help/#findComment-291743 Share on other sites More sharing options...
tqla Posted July 7, 2007 Author Share Posted July 7, 2007 hey pocobueno1388! you are awesome. i would have never thought of that. thanks! Link to comment https://forums.phpfreaks.com/topic/58798-solved-protecting-pages-help/#findComment-291790 Share on other sites More sharing options...
tqla Posted July 7, 2007 Author Share Posted July 7, 2007 Hi PocoBueno, I went a step further with your suggestion and created an auth.inc file like this: <?php session_start(); if (!isset($_SESSION["barcode"])) { header('Location: index.php'); exit; } ?> Then I included this at the top of every protected page: <?php session_start(); include "auth.inc"; ?> Now users get sent to the index page if the variable 'barcode' is not set. 'barcode' is the first variable on the index page. So if they haven't visited the index page first they can't cut in to the other pages. yay! I know this is old hat for most but I thought I'd put it up here on the chance that it may help someone else. Link to comment https://forums.phpfreaks.com/topic/58798-solved-protecting-pages-help/#findComment-292001 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.