jnerotrix Posted January 20, 2009 Share Posted January 20, 2009 I have an administration page i have a mysql database popcornpetz_main TABLE: admin (3) Fields username password id (auto Increment) ------------------- I need it so that user must be logged in to view the admin page but i am unsure of how to do this there is no register page needed i just need the page to show if the user is logged in and to show something else if they are not maybe with a session or something but i dont know how also i need a logout button. so it would be like this if admin is logged in { show this } else { show this } thanks for any help jnerotrix Link to comment https://forums.phpfreaks.com/topic/141669-php-admin-login/ Share on other sites More sharing options...
jjacquay712 Posted January 20, 2009 Share Posted January 20, 2009 if ( $_SESSION['admin'] ) { //echo the page } else { //GTFO NOOB! } Link to comment https://forums.phpfreaks.com/topic/141669-php-admin-login/#findComment-741567 Share on other sites More sharing options...
jnerotrix Posted January 20, 2009 Author Share Posted January 20, 2009 ok now i just need to make the login page This is login.php <form action="login2.php" method="post"> UserName: <input type="text" name="user"><br> Password: <input type="password" name="pass"><br> <input type="submit" value="LOGIN"> </form> What Woulf i put on the login2.php page to check if the login info was correct then put them into a session Link to comment https://forums.phpfreaks.com/topic/141669-php-admin-login/#findComment-741577 Share on other sites More sharing options...
Zane Posted January 20, 2009 Share Posted January 20, 2009 you're going to need to put session_start(); at the very beginning of every page you want authorized...or restricted. Also you're login pages will need it too, even though they aren't restricted, session_start allows your login page to actually USE the session. Link to comment https://forums.phpfreaks.com/topic/141669-php-admin-login/#findComment-741589 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.