cjbeck71081 Posted September 6, 2008 Share Posted September 6, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/123012-date-triggered-email-notifications/ Share on other sites More sharing options...
.josh Posted September 6, 2008 Share Posted September 6, 2008 cron job Quote Link to comment https://forums.phpfreaks.com/topic/123012-date-triggered-email-notifications/#findComment-635202 Share on other sites More sharing options...
Fadion Posted September 6, 2008 Share Posted September 6, 2008 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'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/123012-date-triggered-email-notifications/#findComment-635204 Share on other sites More sharing options...
The Little Guy Posted September 6, 2008 Share Posted September 6, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/123012-date-triggered-email-notifications/#findComment-635208 Share on other sites More sharing options...
cjbeck71081 Posted September 6, 2008 Author Share Posted September 6, 2008 Thanks for the help, Cron job it is, i'll read up on it. How is the event triggered though, does someone have to visit a page, or does it automatically get sent? Quote Link to comment https://forums.phpfreaks.com/topic/123012-date-triggered-email-notifications/#findComment-635231 Share on other sites More sharing options...
.josh Posted September 6, 2008 Share Posted September 6, 2008 when you get around to reading up on cron jobs, you will find that it's basically telling the server to run your script every X time. Quote Link to comment https://forums.phpfreaks.com/topic/123012-date-triggered-email-notifications/#findComment-635233 Share on other sites More sharing options...
DarkWater Posted September 6, 2008 Share Posted September 6, 2008 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! Quote Link to comment https://forums.phpfreaks.com/topic/123012-date-triggered-email-notifications/#findComment-635244 Share on other sites More sharing options...
cjbeck71081 Posted September 6, 2008 Author Share Posted September 6, 2008 You guys are awesome. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/123012-date-triggered-email-notifications/#findComment-635262 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.