jeppers Posted May 22, 2007 Share Posted May 22, 2007 can any one give me a script which will show me how session control works... i have been confused for along time so this is my last chance to it before i have to hand my project in.... it sad that i have brought my self to this level but it too hard too late thanks peeps i hope you can and will help i am so stuck Quote Link to comment https://forums.phpfreaks.com/topic/52467-solved-i-need-help-more-than-ever-please-help/ Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 Do you really want us to write another tutorial just for you? Surely, the 10,000,000 on google are enough. What part exactly do you not understand? Do you have any code? Quote Link to comment https://forums.phpfreaks.com/topic/52467-solved-i-need-help-more-than-ever-please-help/#findComment-258876 Share on other sites More sharing options...
MasterACE14 Posted May 22, 2007 Share Posted May 22, 2007 Do you really want us to write another tutorial just for you? Surely, the 10,000,000 on google are enough. Classical lol Quote Link to comment https://forums.phpfreaks.com/topic/52467-solved-i-need-help-more-than-ever-please-help/#findComment-258879 Share on other sites More sharing options...
jeppers Posted May 22, 2007 Author Share Posted May 22, 2007 fair enough well just this then i want to assign a password to an admin page but i have read so many tutorials i am confused can you give me an example of what it could be like to protect a page using a flat file password system to store the users passwords.. sad but i am begging lol Quote Link to comment https://forums.phpfreaks.com/topic/52467-solved-i-need-help-more-than-ever-please-help/#findComment-258880 Share on other sites More sharing options...
jeppers Posted May 22, 2007 Author Share Posted May 22, 2007 do you know where a good tutorial is please can i have the link thanks Quote Link to comment https://forums.phpfreaks.com/topic/52467-solved-i-need-help-more-than-ever-please-help/#findComment-258896 Share on other sites More sharing options...
trq Posted May 22, 2007 Share Posted May 22, 2007 A simple example (Not tested). login.php <?php $n = 'usernamehere'; $p = 'passwordhere'; session_start(); if (isset($_SESSION['logged'])) { // already logged in. header("Location: index.php"); } if (!isset($_POST['submit'])) { echo "<form method=\"post\">"; echo " <input type=\"text\" name=\"uname\">"; echo " <input type=\"password\" name=\"upass\">"; echo " <input type=\"submit\" name=\"submit\">"; echo "</form>"; } else { if ($_POST['uname'] == $p && $_POST['upass'] == $you) { $_SESSION['logged'] = true; header("Location: index.php"); } else { // login failed. header("Location: {$_SERVER['PHP_SELF']}"); } } ?> Then, on index.php you would just need this at the top. <?php session_start(); if (!isset($_SESSION['logged'])) { // not loged in. header("Location: login.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/52467-solved-i-need-help-more-than-ever-please-help/#findComment-258903 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.