Jump to content

Need help with script which will keep member logged in using cron


Colleen78

Recommended Posts

RE EDITED NOW DEF WORKS

 

 

now there a entry we need to get lastactivity in the databse to

 

update each time correctly

 

trying to throw the database around to show the lastactivety and last access correctly get me babes

 

try

<?php
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

$time_now=time();
//$time_now=strtotime(date("dmy"));// if timestamp in database

$time_now=mysql_real_escape_string($_POST['time_now']);
$userid=mysql_real_escape_string($_POST['userid']);

$result1 = mysql_query("SELECT * FROM user WHERE userid = '503'")
or die(mysql_error()); 

while($row1=mysql_fetch_assoc($result1)){

$time_now2=$_POST['time_now2'];

$time_now2=$row1['lastactivity'];

$result = mysql_query("UPDATE user SET lastactivity='$time_now', 
lastvisit='$time_now2' WHERE userid='503' ") 
or die(mysql_error());  

}
?>

Guys DON'T use PHP to calculate the datetime, use MySQLs nice handy built in functions.

i.e. use CURRENT_TIMESTAMP or NOW()

 

thus

 

$sql = "UPDATE user SET lastactivity=CURRENT_TIMESTAMP WHERE userid='503' ";
$result = mysql_query($sql);

end result hope it works tell me

 

<?php
// ######################### REQUIRE BACK-END ############################
require_once('./global.php');

$userid=mysql_real_escape_string($_POST['userid']);

$result1 = mysql_query("SELECT * FROM user WHERE userid = '503'")
or die(mysql_error()); 

while($row1=mysql_fetch_assoc($result1)){

$time_now2=mysql_real_escape_string($_POST['time_now2']);

$time_now2=$row1['lastactivity'];

$result = mysql_query("UPDATE user SET lastactivity=NOW(), 
lastvisit='$time_now2' WHERE userid='503' ") 
or die(mysql_error());  

}
?>

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.