Jump to content

[SOLVED] calling db


chanfuterboy

Recommended Posts

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.";

}

 

?>

Link to comment
https://forums.phpfreaks.com/topic/169113-solved-calling-db/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/169113-solved-calling-db/#findComment-892261
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/169113-solved-calling-db/#findComment-892294
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/169113-solved-calling-db/#findComment-893115
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.