我設計了一個應用程序並使用phonegap構建所有工作正常,但是當我的mysql數據庫中附加應用程序的值更新時,我希望自動發送電子郵件給用戶。當計數器完成對runnind中的「狀態」值的計數時,廣告表中的數據會更新,並且我希望每次更新該值時發送一封電子郵件,以下是我爲要發送的電子郵件編寫的腳本,但我不知道如何自動的話,請用什麼我能幫助應該還是可以如何在MySQL數據庫中更新值時自動發送電子郵件
<?
include('../db_connect.php');
require_once "PHPMailer-master/class.phpmailer.php";
$id=$_GET["rid"];
$status = 3;
mysql_query("update runningAds set status = 3 where id = '$id'");
// get username
$qaz = mysql_query("select * from runningAds where id = $id") or die (mysql_error());
$wsx = mysql_fetch_array($qaz);
$username = $wsx["users"];
$stopTime = $wsx['stopTime'];
sendConfirmationEmail($username, $stopTime);
header("location: ../view_running_ads.php");
function sendConfirmationEmail($username, $stopTime)
{
$result2 = mysql_query("select * from dapUsers where userName='$username'");
$row = mysql_fetch_array($result2);
$to = $row['email'];
//$from = "[email protected]";
$subject = 'Advert Runtime Alert';
$message = "Dear $username,<br \>
Your display picture advert runtime has ended at $stopTime. <br \>
Advert Direct Team";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
$headers .= 'From: <[email protected]>' . "\r\n";
mail($to,$subject,$message,$headers);
}
?>
請解釋一下狀況view_running_ads.php – 2014-09-24 11:36:34