Last updated on January 19th, 2022 at 08:12 am
This is another tutorial which shows how to create a birthday script which automatically send wishes to the person on that particular day using php and mysql.Pretty simple.All you have to do is take care of the DB part and change it according to your convenience.
Assuming that your table name is bday_table and one of the column that has the date is bday_check.
<?php
$date = date("Y/m/d"); //here my date format in my DB is 2010/09/30
$link = mysqli_connect('HOST','USERNAME','PASSWORD','DATABASE');
if($link && mysqli_select_db('DATABASE', $link))
{
$grabBday = "SELECT * FROM bday_table WHERE bday_check = $date";
//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');
}
}
} ?>
All you need to create is a DB just similar to the above script structure and run this script as a cron.
You can also run this script in your index page or any other webpages [Make sure that the script is executed only once in a day, you need to configure it accordingly.].
In this script we are using the simple mail() function. But you can refer these tutorials if you would like to send
2] Send Email to Multiple Recipients
3] Send HTML email using sendmail
This information is very usefull, but i’m wonderring how do i install it i mean, do I just place it in my folder name Style or something? and do i call the script or should i run a cron job, how will it take effect? can you please advised me on this. That will be so great. Anticipating thanks
Hello, Thank you so much for your comment. You can run this script either as in a CRON as you said or even when an admin/user try to hit some link, for instance some link named TODAY’s B-DAY and direct the link to a php page that contains the above script. You can call the script by any one of these methods, but ultimate decision on where to use to script is yours. 🙂
Hi!
Can you email this script the link seen to be broken
Simple birthday script using php and mysql
Regards
Hi Manjeet,
The link has been fixed. Thanks for bringing this to my attention.
anyone can share a sample script of this? i am really new to php