I would like to run a birthday.php script using Cron and I need some help with the script
I have a table called Members and one field is called "Date of birth".
So I need some sort of query that selects all birthday celebrants for today...and send them an email using runner_mail
I know its only a few lines of code but can't get it to work in the phprunner enviroment.
This is what i got so far ( but not using the phorunner enviroment, as in addressing the database seperate in this example)
( fields in members table: 'Date of birth', Name, email
I need some help converting this to a script in which runner_mail and the database connection is done using phprunner
<?php
$date = date("m-d");//here my date format in my DB is 12/29, basically it grabs the current date
$today=date("Y-m-d");
$link = mysqli_connect('localhost','root','','portal');
if($link)
{
$grabBday = "SELECT * FROM members WHERE `Date of birth` LIKE '%-".$date."'";
//here it will take the name of the person whose bday is on a particular date
$result = mysqli_query($link,$grabBday);
if (mysqli_num_rows($result) > 0) {
// output data of each row
while($row = mysqli_fetch_assoc($result)) {
echo $row["Name"]."'s Birthday Is Today ".$row["Date of birth"]." An email will be sent to ".$row["email"].".
";
// mail($row["email"], 'HAPPY BIRTHDAY', 'MESSAGE');
//runner_mail(array('to' => $row["email"], 'subject' => "test onderwerp", 'body' => "Dit is een mooi bericht"));
}
} else {
echo "0 results";
}
mysqli_close($link);
} ?>