Trouble inserting values in to table after login...
Posted: Sun Sep 25, 2011 7:58 pm
The following code displays validating login and password. If true then "member-index.php" is called. I want to insert values in a table called "last-login" but, although the code seems to function properly, nothing gets populated in the "last-logn" table. As always, I appreciate your help.
Clark
Code: Select all
//Create query
$qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'";
$result=mysql_query($qry);
//Check whether the query was successful or not
if($result) {
if(mysql_num_rows($result) == 1) {
//Login Successful
[color=#BF0000]$query="INSERT INTO `Users`.`last_login` (`member_id`, `login_time`, `login_date`, `logout_time`, `logout_date`) VALUES (2, CURTIME(), CURDATE(), \'\', \'\')";
mysql_query($query);[/color]
session_regenerate_id();
$member = mysql_fetch_assoc($result);
$_SESSION['SESS_MEMBER_ID'] = $member['member_id'];
$_SESSION['SESS_FIRST_NAME'] = $member['firstname'];
$_SESSION['SESS_LAST_NAME'] = $member['lastname'];
session_write_close();
header("location: member-index.php");
exit();
}else {
//Login failed
header("location: login-failed.php");
exit();
}
}else {
die("Query failed");
}