How would I "build-in" an autologin to this script?
if (isset($_POST['login'])) {
$query = mysql_query("
SELECT * FROM users
WHERE user_name = '".mysql_real_escape_string($_POST['username'])."'
AND user_password = '".mysql_real_escape_string($_POST['password'])."'
");
/* wrong login information? terminate the script */
if (!mysql_num_rows($query)){
header("Location: ./");
exit();
}
/* set session with unique index */
$_SESSION['id'] = mysql_result($query, 0, 'user_id');
mysql_query("UPDATE users SET user_online = '1' WHERE user_id = '{$_SESSION['id']}'");
header("Location: ./");
exit;
}
No comments:
Post a Comment