Jump to content

Please help me... This code is killing me


clown[NOR]

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/51423-please-help-me-this-code-is-killing-me/
Share on other sites

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.