dhanasekar Posted February 18, 2012 Share Posted February 18, 2012 Hi... i am very new to php.., i need php script to calculate todays birthday.....and mail should send to customer after click on submit button.. thanks in advanceDHANA Link to comment Share on other sites More sharing options...
TheGallery Posted February 19, 2012 Share Posted February 19, 2012 What do you mean you need a php script? You want us to give you the code? That way you'll keep being new to php for months...i'll guide you and you can write the script on your own. Make a function that will accept one parameter(that will be the email of the user) and will send the email (with your desired content) to the user. Then make another function that will run when you click the button you want. That function should compare the current date with the birthdays in your database. Every time you get a match you can retrieve the user email from the database and call the first function i mentioned. Start writing your code and i'll help you with it. P.S. : I don't know if it's faster/best practice to send the emails while fetching the database or saving them in an array first. Let's hope someone will make it clear. 1 Link to comment Share on other sites More sharing options...
dhanasekar Posted February 20, 2012 Author Share Posted February 20, 2012 Hi.. this is wat i tried .<?php//$custdob=date("2001-05-05");$custdob = date("Y/m/d"); //here my date format in my DB is 2010/09/30$link = mysqli_connect('localhost','root','','multinf');if($link && mysqli_select_db('multinf', $link)){ echo $grabBday = "SELECT * FROM custmast WHERE custdob = $custdob";//here it will take the name of the person whose bday is on a particular date if($rs = mysqli_query($link, $grabBday)) { while(mysqli_fetch_array($rs)) { mail('TO_EMAIL', 'HAPPY BIRTHDAY', 'MESSAGE'); } }} ?> after clicking on submit button.. a mail should send to customers mail..pl help.. thanks in advance Link to comment Share on other sites More sharing options...
[dx] Posted February 20, 2012 Share Posted February 20, 2012 (edited) <?PHP $link = mysqli_connect('localhost', 'root', 'multinf');if ($link && mysql_select_db('multinf', $link)) { $result = mysql_query("SELECT * FROM custmast WHERE custdob='".date('Y/m/d')."'"); while ($r = mysql_fetch_array($result)) { mail($r['email'], 'HAPPY BIRTHDAY', 'MESSAGE'); }} ?> But you shoud make some checker to send only one per day, or script will execute it every time when it loads.. Edited February 20, 2012 by Haris S Link to comment Share on other sites More sharing options...
birbal Posted February 20, 2012 Share Posted February 20, 2012 (edited) $custdob = date("Y/m/d"); //here my date format in my DB is 2010/09/30 extract()You can use extract() to match the only day and month part in database. it will set the year of present timestamp so it will not match with birth year of users in database. You can store the result emails in a array and implode it to string mail() can send email in multiple email id seprating by comma and can call it once to send the emails while(mysqli_fetch_array($rs)){$sendTo[]=$rs['email']; }mail(implode(',',$sendTo),'HAPPY BIRTGADAY','YOUR MSG'); http://php.net/mailhttp://php.net/implode and if its suppose to be run once for notification better will be to run it in cron jobs for day interval. Edited February 20, 2012 by birbal 1 Link to comment Share on other sites More sharing options...
thescientist Posted February 20, 2012 Share Posted February 20, 2012 I would probably make sense to have a cron script run each day so the script only runs once. have it check for the date, look in the database for all birthdays that fall in this day (the beginning of the day to the end of the day) and then send out an email based on that. The email might as well come from the DB too. 1 Link to comment Share on other sites More sharing options...
dhanasekar Posted February 21, 2012 Author Share Posted February 21, 2012 will check it.. friend.... Link to comment Share on other sites More sharing options...
dhanasekar Posted February 22, 2012 Author Share Posted February 22, 2012 extract()You can use extract() to match the only day and month part in database. it will set the year of present timestamp so it will not match with birth year of users in database. You can store the result emails in a array and implode it to string mail() can send email in multiple email id seprating by comma and can call it once to send the emails while(mysqli_fetch_array($rs)){$sendTo[]=$rs['email']; }mail(implode(',',$sendTo),'HAPPY BIRTGADAY','YOUR MSG'); http://php.net/mailhttp://php.net/implode and if its suppose to be run once for notification better will be to run it in cron jobs for day interval. please write full php code for what you have said friend.. i tried friend , but it doesnt work.... Link to comment Share on other sites More sharing options...
thescientist Posted February 22, 2012 Share Posted February 22, 2012 why don't you show us what you did, then we can help you with that. Were not in the habit of doing work for people. You should make sure you are doing some basic logging and have errors turned on. Tell us what you are stuck on and what errors you are getting. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now