Notification 7 Days Before Payment PHP No Error Message
Posted
by
user1858672
on Stack Overflow
See other posts from Stack Overflow
or by user1858672
Published on 2012-11-28T05:01:50Z
Indexed on
2012/11/28
5:04 UTC
Read the original article
Hit count: 148
So I have PHP script running on cron daily. It is suppose to check the date and send an email if it is 7 days before any payments as a reminder. I haven't used PHP in a long time so sorry if the way I did it was ridiculous or something. Thanks a lot. I would say what the problem is but I don't get any error message or anything..
<?php
mysqli_connect("xxxxxx", "xxxxxxx", "xxxxxxxxx") or die(mysqli_error());
mysqli_select_db("xxxxxxxxx") or die(mysqli_error());
//Retrieve original payment dates and enter them into an array
$result = mysqli_query("SELECT DateCreated FROM UserTable");
$payment_dates = mysqli_fetch_array($result);
//Puts original payment date into month-day format
$md_payment_dates = substr($payment_dates, 5);
//Gets todays date in m-d format and adds 7 days to it
$due_date = mktime(0, 0, 0, date("m"), date("d")+7);
//Checks if any payment days match today's date. If there are none it script will stop.
if (count(preg_grep($due_date, $md_payment_dates)) > 0) {
//Retrieves usernames of users that have an invoice due.
$users_to_pay = mysqli_fetch_array("SELECT Username IN UserTable WHERE DateCreated = $date");
//Notifies you via email
$to = "[email protected]";
$subject = "7 Day Payment Reminder";
$message = "Hi, <br /> The following owe a payment in 7 days : " + $users_to_pay ".<br/> Their payments are due on " + $md_payment_dates " of this year.";
mail($to, $subject, $message);
exit();
}else{
exit();
}
?>
© Stack Overflow or respective owner