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());  

}
?>

Link to comment
Share on other sites

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);

Link to comment
Share on other sites

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());  

}
?>

Link to comment
Share on other sites

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.