Jump to content

Recommended Posts

I am developing a CMS for a client who is interested in allowing every day people who sign up to be part of the system to put property listings online.  The client wants to be able to notify the person who placed the property listing when thier property has been online for 30 days, that they must renew the property by updating it's details.

 

Anyone have any ideas, where i might be able to head, or what this is even called?  Server Triggered Email Notification?

 

As well, if they have not updated thier information i would like to take thier listing down.  I figure I can use the timestamp, but I wondered if there was a better method.

 

 

Link to comment
https://forums.phpfreaks.com/topic/123012-date-triggered-email-notifications/
Share on other sites

This seems like a scenario where a cron job does the work perfectly. Your listings in the database should have a "date" field which stores the date when the listing was added. Then the cron job just checks if that listings has passed 30 days and send the email to the author. A sample code:

 

<?php
$member = '[email protected]'; //the email of the users, retrieved from the database
$date = '2008-09-06'; //this will be retrieved from the database
$nextdate = date('Y-m-d', strtotime("$date +30 days")); //calculate the date after 30 days
$today = date('Y-m-d'); //the actual date
if($today > $nextdate){ //if the 30 days period has passed
    mail($member, 'Listing Expired', 'Your listing #4453 has expired. Please renew it');
}
?>

I think I would use a unix timestap simple Examples:

time();

//OR
strtotime("now");

 

Then all you need to do is subtract the two (time in db, and now) to get a difference (in seconds).

30 days = 2592000 seconds

 

just divide 2592000 by your your difference to get days... I think... You my need to mess around with the subtracting and dividing.

Yeah, you basically set exactly when you want your script run, and the server triggers the running.  Ex:

 

0 0 * * * /usr/bin/php -f /home/DarkWater/somescript.php

 

Would run "/home/DarkWater/somescript.php" every day at midnight.

 

P.S:  4000th post! :D

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.