Jump to content

sending a email after X time(solved)


elexion

Recommended Posts

hello everyone i'm trying to write a function that check if there are members that havent activated their account yet.this is the code i've written so far.

<?phpfunction send_reminder(){include("connect.php");$remind= (time()-(60*60*24*14));$myquery = mysql_query("SELECT * FROM tmp_registers WHERE date= CURDATE() - $remind");	while($result= mysql_fetch_array($myquery)){$to = $result['email'];$subject = "Wait dont forget about us!";$message = " content ";$from = "noreply@mystery.com";$headers = "From:" . $from;mail($to,$subject,$message,$headers);}}?>

so this is what i have right now but i'm not quite sure if this is working since i just added the date colum to my table. so 99% of the records are blank set to the default value of 0000-00-00 00:00:00...is it wise to also take in the hour minutes and seconds? well bottom line, Will this run properly? and would this script send out an email everytime some goes to the page this is included in?

Link to comment
Share on other sites

The time may be overkill but you will need the date the members registered. Then compare that date with today's date, if X amount of days have passed since they registered, send the email out.

if ($date_registered < $a_difference_of_a_week) {  // send out emails}

You will also need to make sure that this script only runs only one time a day, when I did something like this, I had a database field with the date the script last ran. If the date was yesterday, the script would run and update the date in the database and set it for today. So something like:

if ($today != $date_script_last_ran) {// run your emailing script// update date in database and set for today}

Link to comment
Share on other sites

cron jobs would do what you need once you figure out your condition for when to send an email notification.

Link to comment
Share on other sites

I'm not quite sure how to set a variable that allows me to look back those 14 days so far i've tried $twoweeks = strtotime('-14 days'); abd $remind= (time()-(60*60*24*14)); but none of those seem to work. I'm completely new to checking time with PhP. Right now i'm working according to Err's examples i just dont know how to fill $a_difference_of_a_week.SOLVED, Will upload final code once my host comes back up

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...