aodat2 Posted August 14, 2008 Share Posted August 14, 2008 I have something which I find quite interesting. Till now I have yet to find any answers or anything which is close or even resembles what I really need. This is basically what I have... Page 1 --> Page 2 --> Page 3 --> Page 4 My problem is how do I make it in such a way that someone needs to actually go to Page 1 before going to Page 2, 3 or 4? Is there a way to actually do this? I would appericiate it if someone could help tell me what I could do to get this going. Thank you very much. Quote Link to comment https://forums.phpfreaks.com/topic/119656-php-page-security-help/ Share on other sites More sharing options...
The Little Guy Posted August 14, 2008 Share Posted August 14, 2008 A session. if the session for a certain page isn't set, don't allow them on that page, and just redirect them to the page where the session is set. Quote Link to comment https://forums.phpfreaks.com/topic/119656-php-page-security-help/#findComment-616451 Share on other sites More sharing options...
wildteen88 Posted August 14, 2008 Share Posted August 14, 2008 An example: <?php session_start(); // set our variables, if they are not set we'll set a defaul value. $_SESSION['pageN'] = isset($_SESSION['pageN']) ? $_SESSION['pageN'] : 1; $page = isset($_GET['page']) ? $_GET['page'] : 1; // check to see if the pageN session matches the requested page if($_SESSION['pageN'] == $page) { $_SESSION['pageN']++; echo '<h1>Page' . $page . '</h1>'; } // page does not match, redirect user else { unset($_SESSION['pageN']); header('Location: test.php'); } ?> <a href="?page=1">Page 1</a><br /> <a href="?page=2">Page 2</a><br /> <a href="?page=3">Page 3</a><br /> <a href="?page=4">Page 4</a><br /> Try going to 2, 3 or 4 first and you'll go back to 1. Quote Link to comment https://forums.phpfreaks.com/topic/119656-php-page-security-help/#findComment-616472 Share on other sites More sharing options...
aodat2 Posted August 14, 2008 Author Share Posted August 14, 2008 As much as I would say "yes" to it, I seem to be having some problem with Sessions. Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by.... Not sure what's wrong at all. In my entire page, I have nothing else other than a few JavaScripts and a Form in HTML. Not even sure what's wrong at all. Can someone help? Quote Link to comment https://forums.phpfreaks.com/topic/119656-php-page-security-help/#findComment-616475 Share on other sites More sharing options...
wildteen88 Posted August 14, 2008 Share Posted August 14, 2008 session_start must be called before any output, eg <?php session_start(); ?> .... your html ... <?php // rest of your PHP ?> .. more html It cannot be .... your html ... <?php session_start(); // rest of your PHP ?> .. more html Quote Link to comment https://forums.phpfreaks.com/topic/119656-php-page-security-help/#findComment-616478 Share on other sites More sharing options...
The Little Guy Posted August 14, 2008 Share Posted August 14, 2008 As much as I would say "yes" to it, I seem to be having some problem with Sessions. Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by.... Not sure what's wrong at all. In my entire page, I have nothing else other than a few JavaScripts and a Form in HTML. Not even sure what's wrong at all. Can someone help? Second Example on page: http://www.phpfreaks.com/forums/index.php/topic,209860.0.html Quote Link to comment https://forums.phpfreaks.com/topic/119656-php-page-security-help/#findComment-616482 Share on other sites More sharing options...
aodat2 Posted August 14, 2008 Author Share Posted August 14, 2008 Thanks a lot wildteen88. Got it working now Really appericiate everyone that chipped in to help. Quote Link to comment https://forums.phpfreaks.com/topic/119656-php-page-security-help/#findComment-616485 Share on other sites More sharing options...
aodat2 Posted August 14, 2008 Author Share Posted August 14, 2008 By the way... since you have already given me an example on what to put in Page 1, what am I suppose to put in Page 2, 3 and 4? Mind helping on that as well? Is your code on pageN suppose to be that as well? Thanks a lot for the help. By the way, I'm seriously a noob on this... never programmed in PHP in my life b4. Haha... LOL. Quote Link to comment https://forums.phpfreaks.com/topic/119656-php-page-security-help/#findComment-616489 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.