我刚刚制作了一个 php 脚本,它将在约会开始前 2 天向网站管理员发送电子邮件提醒。我打算自动化脚本以运行 cron 作业,只是意识到我托管的人(疯狂的域)似乎没有 Cron 作业
没有 cron-jobs 有没有办法做到这一点?如果是这样的话,我不介意去找不同的服务提供商;我已经做了很多搜索,到目前为止我的理解是我需要 Cron Jobs 来处理这些类型的事情?
这是我到目前为止所做的脚本:
<?php include "../connect-to-database.php"; ?>
<?php
$date = date("Y-m-d");
$mod_date = strtotime($date."+ 2days");
$newDate = date("m/d/Y",$mod_date);
$sqlCommand = "SELECT * FROM eventcalender WHERE eventDate='$newDate'" ;
$query = mysql_query($sqlCommand) or die(mysql_error());
$count = mysql_num_rows($query);
if ($count >= 1){
while($row = mysql_fetch_array($query)){
$ID = $row["ID"];
$schedule_title = $row["Title"];
$schedule_description = $row["Detail"];
$importance_level = $row["importance_level"];
$meeting_datetime = $row["eventDate"];
$contacts_involved = $row["contacts_involved"];
$meeting_occurred = $row["meeting_occurred"];
$mid = mysql_insert_id();
$search_output .= "<ul>
<li>
<h4>".$schedule_title."</h4>
<p><b>Time: ".$meeting_datetime."</b></p>
<p>People/Persons involved: ".$contacts_involved."</p>
<p>Meeting Occurred?: ".$meeting_occurred."</p>
<a href='uniqueMeeting.php?ID=".$ID."'>View more details of this meeting</a>
<p><a href='editschedulePage.php?mid=$ID'>Edit This Meeting</a></p>
<p><a href='scheduleList.php?deleteid=$ID'>Delete this meeting</a></p>
</li><br/>
</ul>";
$sendMail = true;
}
}
if($sendMail){
$admin = "SELECT * FROM admin" ;
$queryAdmin = mysql_query($admin) or die(mysql_error());
$adminCount = mysql_num_rows($queryAdmin);
$recipients = array();
if ($count >= 1){
while($row = mysql_fetch_array($queryAdmin)){
$subject ='A-CRM; UpComing Activities';
$msg = $search_output;
$to = $row['email_address'];
mail($to, $subject, $msg);
}
}
}
?>
是的,我确实意识到我是一个不使用 mysqli 的绝对可怕的人,我将在完成这个网站后立即开始