【发布时间】:2016-07-28 19:11:28
【问题描述】:
我希望得到一些帮助。
我想在特定字段中有数据时向特定客户电子邮件发送电子邮件通知。
我已经构建了一个表单,其中客户被重定向到贝宝页面,此时,用户的信息被输入到数据库中。
然后我可以在管理网页上编辑信息,所有信息都从数据库中回显。我要更新的字段名为“shippingnumber”,在客户提交时为空白。当我们在此字段中输入一个数字时,我希望它生成一封电子邮件,然后将其发送到同一行中关联的电子邮件,通知他们订单已发货等,在这种情况下例如“wendybrown@hotmail.com . 下面是我的数据库从 mysql 数据库回显到网页的图片的链接,红色圆圈是我想输入数字的字段,蓝色圆圈是我需要接收一次电子邮件通知的电子邮件shippingnumber 字段输入了一个数字
我已经对此问题进行了一些研究并亲自尝试过,但我无法弄清楚这一点,也无法找到适合我需求的解决方案。请原谅我,因为我是新手,并希望获得一些关于如何实现这一目标的指导。下面是我的 paypalform 的 html 页面,在这种情况下,产品价值 325 美元。
谢谢
HTML:
<form action="PPPaymentForm/PPPaymentForm.php" method="post" name="topchoiceform" id="topchoiceform">
<input placeholder="Company Name" type="text" name="companyname" required>
<input placeholder="First Name" type="text" name="firstname" required>
<input placeholder="Last Name" type="text" name="lastname" required>
<input placeholder="Email" type="email" name="email" required>
<input placeholder="Address" type="text" name="address" required>
<input name="shipping" class="shipping" type="checkbox" id="shipping" value="19.99"/>
<label class="shippingcheck">19.99(Optional Shipping, will be added to total if choosen)</label>
<br>
<br>
<button name="submit" type="submit">Pay Now</button>
<input type="hidden" name="hdwtablename" id="hdwtablename" value="1">
<input type="hidden" name="hdwppproductname" id="hdwppproductname" value="Bronze Plan 325">
<input type="hidden" name="hdwppamount" id="hdwppamount" value="325">
<input type="hidden" name="hdwppcurrency" id="hdwppcurrency" value="USD">
<input type="hidden" name="hdwpplanguage" id="hdwpplanguage" value="en_US">
<input type="hidden" name="hdwok" id="hdwok" value="">
<input type="hidden" name="hdwemail" id="hdwemail" value="something+gmail.com">
<input type="hidden" name="hdwnook" id="hdwnook" value="http://">
<input type="hidden" name="hdwactivation_email" id="hdwactivation_email" value="email">
<input type="hidden" name="plan" id="plan" value="$325">
<input type="hidden" name="shippingchoosen" id="shippingchoosen" value="">
<input type="hidden" name="shippingnumber" id="shippingnumber" value="">
</form>
嘿,马斯卡连特 感谢您的回复。我使用 hotdreamweaver 脚本中的一个脚本,称为 paypal 付款表单。(www.hotdreamweaver.com/paypal-payment-form)所以它的工作方式是将页面中的 html 表单转换为 paypal 表单,从而生成一个名为“PPPaymentForm/PPPaymentForm.php”的文件夹下面是一个带有php的记事本文档的链接。
http://www.cedarpublishing.com/phpcode.txt
更新
<?php
$connect = mysql_connect("localhost", "username", "password") or die ("Cannot connect");
mysql_select_db("database") or die("Cannot select database");
/*SECTION 2*/
/*
* Checks form field for shipping number, then where shipping has email, send email to recipient
*/
$result = mysql_query("SELECT * FROM table");
$shippingnumber = $_POST['shippingnumber'];
$email = $_POST['email'];
if (isset($_POST['submit'])) {
if(mysqli_num_rows($result) >0)
$row = mysqli_fetch_assoc($result);
$shippingnumber = $row['shippingnumber'];
if(isset($_POST['shippingnumber'])==$row['shippingnumber']){
$to = $_POST['email'];
$first = $_POST['firstname'];
$last = $_POST['lastname'];
$subject = "Product has been shipped";
$subject .= $last;
$subject .= ', ';
$subject .= $first;
$subject .= ')';
$message .= 'Company Name: ' . $_POST['companyname'];
$message = 'First Name: ' . $_POST['firstname'] . "\r\n\r\n";
$message .= 'Last Name: ' . $_POST['lastname'] . "\r\n\r\n";
$message .= 'Address Line 1: ' . $_POST['address'] . "\r\n\r\n";
$message .= 'Email: ' . $_POST['email'] . "\r\n\r\n";
$headers = "From: myownemail@gmail.com\r\n";
$headers .= 'Content-Type: text/plain; charset=utf-8';
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
if ($email) {
$headers .= "\r\nReply-To: $email";
}
$success = mail($to, $subject, $message, $headers);
}
}
/*SECTION 3*/
/*
* Checks if the shipping number exists and look for email in that row which belongs to that shipping number to send email out.
*/
$sql = "SELECT COUNT(*) FROM topchoiceform WHERE shippingnumber = '$shippingnumber' AND '$shippingnumber' MATCHES $email";
$result = mysql_query($sql)or die('Could not find member: ' . mysql_error());
if(mysqli_num_rows($result) >0){
$row = mysqli_fetch_assoc($result);
if($shippingnumber = $row['shippingnumber']){
echo "It exists";
}
}else{
echo "No matching shipping number found upon sql call";
}
?>
【问题讨论】:
-
您需要更好地描述您的代码,因为在这种情况下,HTML 对我们没有多大帮助。我可以看到您正在将此 HTML 文档提交到 PHP 页面,我们可以看看吗?任何电子邮件发送都需要在服务器端完成。
-
嘿马斯卡连特感谢您的回复。我使用 hotdreamweaver 脚本中的一个脚本,称为 paypal 付款表单。(www.hotdreamweaver.com/paypal-payment-form)所以它的工作方式是将页面中的 html 表单转换为 paypal 表单,从而生成一个名为“PPPaymentForm/PPPaymentForm.php 的文件夹下面是一个带有 php 的记事本文档的链接。cedarpublishing.com/phpcode.txt
-
@MannySmith - 请停止尝试使用更新的代码编辑答案。这应该添加到问题中,而不是某人的答案中。
-
嗨,andrewsi,我很抱歉,这是我第一次使用 stackoverflow。
标签: javascript html mysql email triggers