clown[NOR] Posted May 15, 2007 Share Posted May 15, 2007 it just wont write the $new_timestamp to the database... can anyone see any errors ? it's probably a smal thing, but I think i've goe blind <?php function authUser() { if (!empty($_COOKIE['user']) || !empty($_COOKIE['sid']) || !empty($_COOKIE['access'])) { $user = $_COOKIE['user']; $sid = $_COOKIE['sid']; $axx = $_COOKIE['access']; dbConn(); $query = "SELECT * FROM `news_users` WHERE email ='".$user."' AND sid ='".$sid."' AND access ='".$axx."' LIMIT 1"; $result = mysql_query($query); if (!$result) { die(mysql_error()); } $dbRows = mysql_num_rows($result); if ($dbRows > 0) { $dbField = mysql_fetch_assoc($result); $timestamp = date("H:i:s", strtotime("5 minutes ago")); $current_time = $dbField['logintime']; if ($current_time > $timestamp) { // TODO: Logout due to idle setcookie("user", "", time()-3600*24*12); setcookie("sid", "", time()-3600*24*12); setcookie("access", "", time()-3600+24+12); header("Location: ../index.php"); } elseif ($current_time < $timestamp) { // TODO: Update timestamp $new_timestamp = date("H:i:s"); $query = "UPDATE `news_users` SET logintime ='".$new_timestamp."' WHERE email ='".$user."' AND sid ='".$sid."' AND access ='".$axx."'"; $result = mysql_query($query); if (!$result) { die(mysql_error()); } // Set cookies setcookie("user", $user, time()+3600*24*12); setcookie("sid", $sid, time()+3600*24*12); setcookie("access", $axx, time()+3600+24+12); return true; } } else { return false; } } else { return false; } } ?> Thanks In Advance - Clown Quote Link to comment https://forums.phpfreaks.com/topic/51423-please-help-me-this-code-is-killing-me/ Share on other sites More sharing options...
pocobueno1388 Posted May 15, 2007 Share Posted May 15, 2007 If it is a timestamp in the DB, try just using NOW() $query = "UPDATE `news_users` SET logintime = NOW() WHERE email ='".$user."' AND sid ='".$sid."' AND access ='".$axx."'"; Quote Link to comment https://forums.phpfreaks.com/topic/51423-please-help-me-this-code-is-killing-me/#findComment-253269 Share on other sites More sharing options...
clown[NOR] Posted May 15, 2007 Author Share Posted May 15, 2007 oh ok... i changed it to TIME... but I can try anyway... got nothin to lose on it.. EDIT: i tried it, but didn't work... i'm just gonna go sleep now, and re-write the whoe thing when I wake up... thanks for trying tho.. - Clown Quote Link to comment https://forums.phpfreaks.com/topic/51423-please-help-me-this-code-is-killing-me/#findComment-253282 Share on other sites More sharing options...
jitesh Posted May 15, 2007 Share Posted May 15, 2007 $time_before_5_mnt = date("Y-m-d H:i:s",mktime() - 300); $query = "UPDATE `news_users` SET logintime = '".$time_before_5_mnt ."' WHERE email ='".$user."' AND sid ='".$sid."' AND access ='".$axx."'"; Quote Link to comment https://forums.phpfreaks.com/topic/51423-please-help-me-this-code-is-killing-me/#findComment-253285 Share on other sites More sharing options...
clown[NOR] Posted May 15, 2007 Author Share Posted May 15, 2007 thanks,... well.. i just woke up... gonna make me some cofee and re-write the whole thingy... i think there's something messed up in a if statement somewhere... thanks for the help tho... gonna use it in the new version of the function - Clown Quote Link to comment https://forums.phpfreaks.com/topic/51423-please-help-me-this-code-is-killing-me/#findComment-253495 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.