Mysql Query to store datetime in php?

jimmy

New member
This doesn't work:
// Login good, create session variables
$unixtime = time();
$_SESSION["valid_id"] = $obj->id;
$_SESSION["valid_user"] = $_POST["username"];
$_SESSION["valid_time"] = date('Y-m-d H:i:s', $unixtime);

//Add information to user database that indicates logged in status.
$login = "UPDATE users SET status=1 WHERE username='$username'";
$loggedin = mysql_query($login);

$l = "UPDATE users SET time=".$_SESSION["valid_time"]." WHERE username='$username'";
$li = mysql_query($l);


/*
After this script is run, this redirects the user to a members page where the correct username and time are displayed. However, the time field of the database has not been updated. The status field updates correctly.
*/
The line
$username=$_POST["username"];
is run before the point I started the copy-paste.

$obj is the result of
$q = "SELECT * FROM users WHERE username='$username' AND password=PASSWORD('$password') LIMIT 1";
// Run query
$r = mysql_query($q);
if ( $obj = mysql_fetch_object($r) )
 
Back
Top