I have a reminder mail sent to those who do not log on to my site after 30 days. Earlier I got an answer on this forum to create a seperate field and then update it as mentioned here: Need help on unix time stamp.
I have created a new field lastprelogin, now how do I update the respective field when I send the mail for inactive users.
<?php
include("include/data.php");
$query = "SELECT * FROM myusers WHERE DATE_ADD(FROM_UNIXTIME(lastprelogin), INTERVAL 15 DAY) < CURDATE()";
$result = mysql_query($query);
$num = mysql_numrows($result);
$i = 0;
while ($i < $num)
{
//send mail code
$sendmail = mail($to,$subject,$msg,$headers);
$i++;
if($sendmail) {
$query1 = "UPDATE myusers SET lastprelogin='".time()."'";
$result2 = mysql_query($query1);
}
}
?>
How can I update the respective user’s lastprelogin field after sending the mail?
I am lost here beccause am unable to understand the logic in this part.
The logic of Your script is simple:
You have some important errors within Your script and this should be like this:
As a
$headersvariable You can set aFromheader, etc. Look for PHP mail function here: http://php.net/mailAlso the right query for updating should be this one:
anyway You will update the
lastpreloginof all users everytime…