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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.