[英]Fire an automated email when database updated?
I am trying to figure out the best way to send an automated email to a customer when we update our database with "frames in" i'm thinking javascript & php but don't really know how to implement as a nobo!? 我正在尝试找出当我们使用“ frames in”更新数据库时向客户发送自动电子邮件的最佳方式。我在考虑javascript和php,但实际上不知道如何实现为nobo!
<form action="<?php echo $editFormAction; ?>" name="form" method="POST">
<input name="frame_in" type="checkbox" id="long_tiny" value="yes" <?php if (!(strcmp($row_Recordset1['frame_in'],"yes"))) {echo "checked=\"checked\"";} ?> />
<input type="hidden" name="MM_update" value="form">
</form>
$mailTo = $row_customer['email'];
$subject = 'Your Frames Now in!!';
$cName = $row_Recordset2['cName'];
$jobRef = $row_Recordset2['customer_ref'];
$ourRef = $row_Recordset2['our_ref'];
$jobTotal = $row_recordset2['amount'];
mail($mailTo, $subject,
$cName your job Ref: $jobref is now in
<br>
<h2>Details:</h2>
<p>Our ref: $ourRef<br>
Customer Ref: $jobref<br>
Job total: $jobtotal</p>
);
I really don't know how to tie it all together I'm guessing there would need to be error handling as not every customer has an email (But the error doesn't need to be shown) 我真的不知道如何将所有内容结合在一起,我想这将需要进行错误处理,因为不是每个客户都有一封电子邮件(但是不需要显示错误)
$mailTo = $row_customer['email'];
$subject = 'Your Frames Now in!!';
$cName = $row_Recordset2['cName'];
$jobRef = $row_Recordset2['customer_ref'];
$ourRef = $row_Recordset2['our_ref'];
$jobTotal = $row_recordset2['amount'];
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$message = "$cName your job Ref: $jobref is now in
<br>
<h2>Details:</h2>
<p>Our ref: $ourRef<br>
Customer Ref: $jobref<br>
Job total: $jobtotal</p>";
if($_POST['frame_in'] == "yes") {
mail($mailTo, $subject,$message, $headers);
}
This is a very broad question. 这是一个非常广泛的问题。 What you need to do is:
您需要做的是:
$editFormAction
$editFormAction
处理表单 $_POST['frame_in']
is set, do the following: $_POST['frame_in']
,请执行以下操作:
No aditional javascript needed. 无需其他JavaScript。
Where exactly are you stuck? 你到底困在哪里?
You could try a database trigger that sends an email. 您可以尝试发送电子邮件的数据库触发器。 The database itself would be sending out the e-mail, and would not involve php at all.
数据库本身将发送电子邮件,而根本不涉及php。 This would also be more inclusive, as it would send an email regardless or who/what changes the field, including changes from PhpMyAdmin, or other webpages/scripts.
这也将更具包容性,因为它将发送电子邮件,而无论字段是由谁或什么来更改的,包括来自PhpMyAdmin或其他网页/脚本的更改。
http://dev.mysql.com/doc/refman/5.0/en/triggers.html http://dev.mysql.com/doc/refman/5.0/en/triggers.html
http://forums.mysql.com/read.php?99,33635,33635#msg-33635 http://forums.mysql.com/read.php?99,33635,33635#msg-33635
This may be limited depending on your hosting environment. 这可能受到限制,具体取决于您的托管环境。 If you are using shared hosting, odds are you cannot utilize triggers for security reasons.
如果您使用共享主机,则出于安全原因,您不能使用触发器。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.