Website Scripts And Cloud Tutorials

Simple birthday script using php and mysql


Sep 30, 2010

Last updated on January 19th, 2022 at 08:12 am

Click to rate this tutorial!
[Total: 47 Average: 3.7]

PHP Birthday ScriptThis 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.

$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))
            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

1] HTML email using PHP

2] Send Email to Multiple Recipients

3] Send HTML email using sendmail

Click to rate this tutorial!
[Total: 47 Average: 3.7]
5 thoughts on “Simple birthday script using php and mysql”
  1. 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

    1. 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. 🙂

Leave a Reply

Your email address will not be published.