Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.