如何将作业状态更改为“已取消”时,它会向我发送一封电子邮件,通知我提交后的更改?
<form action='phplib/job_update.php' method='post' id='new_job'>
<label for='status'>Job Status</label>
<select name='status' id='status'>
<?php
$sql = "SELECT * FROM status";
$result = mysqli_query($dbc3, $sql);
while($row = mysqli_fetch_assoc($result)){
echo "<option value='" . $row['id'] . "'";
if($row['id'] == $data['status']) echo "selected='selected'";
echo ">" . ucwords($row['name']) . "</option>";
}
?>
</select>
</form>
表格是什么样的:
答案 0 :(得分:0)
有许多方法可以使用PHP发送电子邮件,但我会向您展示最简单的(假设您没有使用任何库或框架)。修改phplib / job_update.php脚本。写入数据库(查找另一个mysqli_query(...)
行)后,添加以下代码:
$cancelledCode = // Easiest way to find this is to view source in the HTML
if ($cancelledCode == $_POST['status']) {
$to = 'you@example.com';
$subject = 'Cancelled Job';
$message = 'Yo, a job has been cancelled. ...';
if (!mail($to, $subject, $message)) {
// Error sending mail
}
}
有关mail()
功能的更多信息,包括设置FROM地址,可在http://www.php.net/mail找到