Jump to content

Getting infomation but how do i know which info?


SirChick

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.

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.