gtal3x Posted December 2, 2007 Share Posted December 2, 2007 Ok here is my script, when you go to the page it should check if the seesion is not registred and display the login form, else it should echo "You are logged in" for some reason it doesnt work and am gettin confused coz its a simple script! <?php $username = "alex"; $password = "mypass"; $submit = $_POST['submit']; $post_user = $_POST['username']; $post_pass = $_POST['password']; if (isset ($submit)) { if (($username != $post_user) || ($password != $post_pass)) { $error .= "<b>Login Failed.</b>"; } if (!$error) { session_register("post_user"); header("location:index.php"); } else { echo $error; } } if (!session_is_registered("post_user")){ ?> <html> <head><title>Admin Page</title></head> <body> <form name="login" method="POST" action="<?php echo $PHP_SELF; ?>" > <table> <tr><td colspan="2"><h1>Admin login:</h1></td></tr> <tr><td><b>Username:</b></td><td><input type="text" name="username"></td></tr> <tr><td><b>Password:</b></td><td><input type="password" name="password"></td></tr> <tr><td><input type="submit" name="submit" value="Login"></td></tr> </table> </form> </body> </html> <?php } else { echo "You are Logged in!"; } ?> Link to comment https://forums.phpfreaks.com/topic/79777-solved-session-doesnt-work/ Share on other sites More sharing options...
rab Posted December 2, 2007 Share Posted December 2, 2007 <?php session_start(); //... rest of your code Link to comment https://forums.phpfreaks.com/topic/79777-solved-session-doesnt-work/#findComment-403996 Share on other sites More sharing options...
gtal3x Posted December 2, 2007 Author Share Posted December 2, 2007 oh dont tell me i did such a stupid mistake....! is it coz its 5:30 am???? Thanks for reply! Link to comment https://forums.phpfreaks.com/topic/79777-solved-session-doesnt-work/#findComment-403997 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.