Hello all,
I tweeked a membership tutorial to work with my database.
Everything works ok....visitors are able to register, go to a confirmation link, and login.
Everything about the user is entered into the members table ok with one big exception ----
I want the last_login field (a datetime column notnull) to be updated everytime they login, but it is not happening. The value stays at the default list of 0's.
Here is the code...if it is more code than needed I apologize.
the db.php file contains all the database connection info and it is good.
Thanks in advance for any help.
<?
/ Check User Script /
session_start(); // Start Session
include 'db.php';
// Conver to simple variables
$username = $POST['username'];
$password = $POST['password'];
if((!$username) || (!$password)){
echo "Please enter ALL of the information! <br />";
include 'login_form.html';
exit();
}
// check if the user info validates the db
$sql = mysql_query("SELECT * FROM members WHERE username='$username' AND password='$password' AND activated='1'");
$login_check = mysql_num_rows($sql);
if($login_check > 0){
while($row = mysql_fetch_array($sql)){
foreach( $row AS $key => $val ){
$$key = stripslashes( $val );
}
// Register some session variables!
session_register('first_name');
$SESSION['first_name'] = $first_name;
session_register('last_name');
$SESSION['last_name'] = $last_name;
session_register('email');
$_SESSION['email'] = $email;
mysql_query("UPDATE members SET last_login=now() WHERE user_id='$userid'");
header("Location: login_success.php");
}
} else {
echo "You could not be logged in! Either the username and password do not match or you have not validated your membership!<br />
Please try again!<br />";
include 'login_form.html';
}
?>