chanfuterboy Posted August 6, 2009 Share Posted August 6, 2009 Hi, need help, i need write a code in my php, i need to see if a person in online from my mysql db, than it can show a page otherwise it show another, can someone help me on that. what i have now is <?php session_start(); require_once("connect.php"); // Check his status. if (!empty($_SESSION[username])) // he got it. { echo "You are currently logged in, <b>$_SESSION[username]</b>."; } else // bad info. { echo "You are currently <b>NOT</b> logged in."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/169113-solved-calling-db/ Share on other sites More sharing options...
smerny Posted August 6, 2009 Share Posted August 6, 2009 not sure what you're looking for exactly.... you could just put more info in the if/else than the one echo? you could use an include within the if/else to show different pages... like if he's not logged in, include the login/register page or something... again not exactly sure what you're looking for Quote Link to comment https://forums.phpfreaks.com/topic/169113-solved-calling-db/#findComment-892261 Share on other sites More sharing options...
chanfuterboy Posted August 6, 2009 Author Share Posted August 6, 2009 Ok, let me write it, maybe it is easy so. after i login. you get page2. The page 2, can be seen only after login. If it is not login, when you go direct to page2, it move you to login.php. I need the script that call the db, to see if id is login in the row, it can show page 2, and not, go login.php Quote Link to comment https://forums.phpfreaks.com/topic/169113-solved-calling-db/#findComment-892294 Share on other sites More sharing options...
mars_rahul Posted August 7, 2009 Share Posted August 7, 2009 Rather then doing include better put something like "REDIRECT('Location:example.php?message='Relogin')". It will take user to desired page. Isn't it? Quote Link to comment https://forums.phpfreaks.com/topic/169113-solved-calling-db/#findComment-892846 Share on other sites More sharing options...
smerny Posted August 7, 2009 Share Posted August 7, 2009 you don't need to call the db to see if he is online.... your script does that already... again it seems unclear what you are after to me Quote Link to comment https://forums.phpfreaks.com/topic/169113-solved-calling-db/#findComment-892935 Share on other sites More sharing options...
gevensen Posted August 7, 2009 Share Posted August 7, 2009 its not clear either you have to validate your user to set your session data if your logging in once you confirm your user you set your session and if your session is set then you can redirect if you want dont forget <?php ob_start();?> after your session starts or you can get a error trying to redirect Quote Link to comment https://forums.phpfreaks.com/topic/169113-solved-calling-db/#findComment-893115 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.