I am learning php and have enrolled in a course. my user login is displayed below.
my question is do i have to select all fields i want in a session when logging in? could i not just use Select email and pull all rows by that or to i have to select all row on login?
example take this uid = uid for that session should it not pull all info about the user with id = id?
$_SESSION['email'] = $email;
$_SESSION['uid'] = $row['uid'];
function login_user($email, $password)
{
$sql = "SELECT pwd, uid, user, birthdate FROM users WHERE email = '" . escape($email) . "' AND active = 1";
$result = query($sql);
if (row_count($result) == 1) {
$row = fetch_array($result);
$db_password = $row['pwd'];
if (password_verify($password, $db_password)) {
$_SESSION['email'] = $email;
$_SESSION['uid'] = $row['uid'];
$_SESSION['username'] = $row['username'];
$_SESSION['birthdate'] = $row['birthdate'];
return true;
} else {
return false;
}
return true;
} else {
return false;
}
}