balkan7 Posted January 14, 2008 Share Posted January 14, 2008 hi guys i got in datebase 2 fields: date_start date_expire now i need check date expire before 1 week expire send to user email ... Quote Link to comment https://forums.phpfreaks.com/topic/85945-solved-send-msg-before-1-week-expire/ Share on other sites More sharing options...
tinker Posted January 14, 2008 Share Posted January 14, 2008 you'll need some kind of cron process to run a script that checks and sends. Depending upon your host influences how your cron is setup, you could even do it manually once a week, or even setup a cron job at home which calls an appropriate script on your server. Quote Link to comment https://forums.phpfreaks.com/topic/85945-solved-send-msg-before-1-week-expire/#findComment-438794 Share on other sites More sharing options...
balkan7 Posted January 14, 2008 Author Share Posted January 14, 2008 yes but i dont have cron job if you can example to code if posible ? Quote Link to comment https://forums.phpfreaks.com/topic/85945-solved-send-msg-before-1-week-expire/#findComment-438795 Share on other sites More sharing options...
dooper3 Posted January 14, 2008 Share Posted January 14, 2008 The script could be something along the lines of... $now=time(); $nextweek=$now+(60*60*24*7); if ($expiry<=$nextweek && $expiry >=$today) { mail($to,$from,$subject, "From: you@yoursite.com"); } Obviously you'd need to stick in your database connection bits around that script and make it a little more detailed than that, but I hope that gives you the idea. After the email was sent you'd also need to make sure that the database was updated to show that, otherwise people would receive multiple emails. Quote Link to comment https://forums.phpfreaks.com/topic/85945-solved-send-msg-before-1-week-expire/#findComment-438798 Share on other sites More sharing options...
balkan7 Posted January 14, 2008 Author Share Posted January 14, 2008 field in date base: field:banner_expire type:datetime Null: yes for expire i used this code: <?php $time = date("Y-m-d H:i:s"); if ($data['banner_expire'] < $time) { $expires = dbquery("UPDATE ".$db_prefix."btr_banners SET banner_state='0' WHERE banner_id='".$data['banner_id']."'"); }?> now if i use your code maybe not working propertly ? Quote Link to comment https://forums.phpfreaks.com/topic/85945-solved-send-msg-before-1-week-expire/#findComment-438878 Share on other sites More sharing options...
balkan7 Posted January 14, 2008 Author Share Posted January 14, 2008 if i use this code can be work? because field in datebase are: datetime null. code: <?php $now=time(); $nextweek=$now+(60*60*24*7); if ($expiry<=$nextweek && $expiry >=$today) { mail($to,$from,$subject, "From: you@yoursite.com"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/85945-solved-send-msg-before-1-week-expire/#findComment-438952 Share on other sites More sharing options...
dooper3 Posted January 14, 2008 Share Posted January 14, 2008 I'm sorry I don't really understand what you're trying to say. As long as you retrieve the expiry time from the database and put it in the variable $expiry then the above code will work. Quote Link to comment https://forums.phpfreaks.com/topic/85945-solved-send-msg-before-1-week-expire/#findComment-438956 Share on other sites More sharing options...
balkan7 Posted January 14, 2008 Author Share Posted January 14, 2008 i can use this way ? <?php $now = date("Y-m-d H:i:s"); $nextweek=$now+(60*60*24*7); if ($data['banner_expire']<=$nextweek && $data['banner_expire'] >=$today) { mail($to,$from,$subject, "From: you@yoursite.com"); } ?> i dont understand what doing variable $today ? Quote Link to comment https://forums.phpfreaks.com/topic/85945-solved-send-msg-before-1-week-expire/#findComment-438966 Share on other sites More sharing options...
dooper3 Posted January 14, 2008 Share Posted January 14, 2008 no, date("Y-m-d H:i:s") is not valid, for the current time/date just use $now=time() as i said above. And sorry, $today should be $now. Quote Link to comment https://forums.phpfreaks.com/topic/85945-solved-send-msg-before-1-week-expire/#findComment-439008 Share on other sites More sharing options...
balkan7 Posted January 14, 2008 Author Share Posted January 14, 2008 soryy for reply i just wanna to know for this code can work propertly, <?php $now = time(); $nextweek = $now+(60*60*24*7); if ($data['banner_expire'] <= $nextweek) { mail($to,$subject,$msg,"From: you@yoursite.com"); } ?> i ask this question because field banner_expire in datebase is: `banner_expire` datetime default NULL, Quote Link to comment https://forums.phpfreaks.com/topic/85945-solved-send-msg-before-1-week-expire/#findComment-439012 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.