I'm trying to extract from users table the user id, but it doesn't work.
Login function:
function login($user, $password) {
$user = strip_tags(mysql_real_escape_string($user));
$password = strip_tags(mysql_real_escape_string($password));
$password = md5($password);
$sql = "SELECT * FROM users WHERE user = '$user' AND password = '$password'";
$result = mysql_query($sql) or die('Error. ' . mysql_error());
if (mysql_num_rows($result) == 1)
{
$_SESSION['access']=true;
$_SESSION["user"] = $user;
$_SESSION["password"] = $password;
$_SESSION["id"] = $id;
header('Location: '.DIR.'admin.php');
exit;
}
else
{
//error
$_SESSION['error'] = 'Wrong name or password.';
}
}
Now when i'm logged in, i tried to post these info on admin.php with echo 'Username ' .$user. 'ID: ' .$id '; it doesn't show.