存在与在某个特定日期发送电子邮件提醒有关的问题。我搜索了一些有用的代码,并且有几个网站介绍了有关cron工作的信息。但我对此一无所知。因此,任何人都可以给我打电话以提供实际答案。在这里,我附上代码。
include('connection.php');
if (isset($_POST['submit'])) {
$name = $_POST['name'];
$mobile = $_POST['mobile'];
$email = $_POST['email'];
$datenoted = $_POST['datenoted'];
$subject = $_POST['subject'];
$sel = "insert into reminders(remindr_name,remindr_mobile,reminder_email,remindr_subject,remindr_date,curdate,curtime) values('$name','$mobile','$email','$subject','$datenoted',CURDATE(),CURTIME())";
if(!mysqli_query($link ,$sel ))
{
echo "Error " .mysqli_error($link);
}
else
{
$sqlCommand = "SELECT
u.remindr_id
, remindr_name
, remindr_subject
, remindr_date
, reminder_email
FROM reminders u
WHERE remindr_date BETWEEN CURDATE() AND CURDATE()+INTERVAL 7 DAY
";
$query = mysqli_query($link, $sqlCommand) or die (mysqli_error($link));
//fetch the data from the database
$message = '';
$email = '';
while ($row = mysqli_fetch_array($query)) {
$arr_ids[] = $row['remindr_id'];
$prev_Email = $email;
$headers = "From: mail@georgeprojects.com\r\n";
$subject = "GeorgeProject Reminder";
$id = $row['id'];
$owner = $row['remindr_name'];
$email = $row['reminder_email'];
if(date("Y-m-d") == $row['remindr_date']) {
if(!empty($email) && $email != ""){
$message = "Hi: {$row['remindr_name']} , \n\n There is a reminder for you on the date : {$row['remindr_date']} regarding the subject {$row['remindr_subject']}\n";
$to = $email;
$sendmail = mail($to, $subject, $message, $headers);
}
}
}
header('Location: reminderInsert.php');
}
}