Jump to content

Recommended Posts

If the user just logged into the main page how do you get the code to load that particular person's details :S

 

 

If i used a SELECT FROM WHERE

 

what do i put under the "WHERE" cos i cant put "where userid = 1 cos then only user id 1 will be displayed even if they are not user id ...what is the logical way to load the correct data?

When a user logins, u compare the submited data with the database ones. If those are equal then u grant them privileges by assigning them a session. U can use the session to save the user's id and then use that session to display that user's personal details in the another page. Ex.

 

login

$query = mysql_query("SELECT * FROM table WHERE user='$user' and pass='$pass'");
if(mysql_num_rows($query) == 1){
    $values = mysql_fetch_array($query);
    $id = $values['id'];
    $_SESSION['logged'] = $id;
}

 

details

$id = $_SESSION['logged'];
$query = mysql_query("SELECT * FROM table WHERE userid='$id'");
$values = mysql_fetch_array($query);
echo $values['name'];
echo $values['surname'];
echo $values['email'];

 

Hope it was helpful.

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.