I have database with last_logoff_date. I recently added new column last_login_date. I am trying to send email to members whose last_login_date is greater than 10 days and less than 120 days. As I have created last_login_date column recently with timestamp atrribute, every row is set as 0000-00-00 00:00:00 by default, and now onwards when member get login to site, current timestamp is added to this field. Now with below code, email is getting send to members with last_login_date 0000-00-00 also and even to members logged in before 1 day too.
In short, email gets delivered to all memebrs with member_status=1 irrespective of last_login_date...
I could not find out the error. This php is script is used for cronjob.
My Code is as follows..
<?php
include("db1.php");
require("class.phpmailer.php");
$mail = new PHPMailer();
$login_check=mysql_query("select * from table name where member_status= '1' AND last_login_date != '0000-00-00' ");
while($datelogin=mysql_fetch_array($login_check)){
mysql_query("select * from table name WHERE reg_id =".$datelogin['reg_id']);
$date1= date("Y-m-d");
$date2=date("Y-m-d",strtotime($datelogin['last_login_date']));
$dateDiff = strtotime($date1) - strtotime($date2);
$fullDays = floor($dateDiff/(60*60*24));
if($fullDays >= 10 && $fullDays <= 121){
ob_start();
?>
email data.....
<?
$body=ob_get_contents();
ob_end_clean ();
........
}
}
?>