简体   繁体   English

使用数据更新/输入字段时如何向行内的特定电子邮件发送电子邮件触发通知

[英]How to send email trigger notification to specific email within row when field is updated/inputted with data

Sorry for sounding like a broken record, i posted a similar question last week and have had some decent progress, but i need to go a step further. 对不起,听起来像是唱片破损,我上周发布了一个类似的问题,并取得了不错的进展,但我需要更进一步。

So i have been pulling my hairs over this and need some guidance and help. 所以我一直在努力,需要一些指导和帮助。 In a nutshell, i need to be able to fill in an empty field(field is called "shippingnumber") within the database or custom back end, which would then trigger a custom email notification to the persons email within the same row. 简而言之,我需要能够在数据库或自定义后端中填写一个空字段(该字段称为“ shippingnumber”),然后这将触发向同一行中的人员电子邮件发送自定义电子邮件通知。 Here is what i got so far. 这是我到目前为止所得到的。 We will be using the email "thisisatestemail2016@gmail.com" as an example. 我们将以电子邮件“ thisisatestemail2016@gmail.com”为例。 This is the email that the person will submit into the form below, and is also the same email which will receive the email notification when the field, "shippingnumber" has data put into it. 这是该人将提交到以下表单中的电子邮件,也是当“ shippingnumber”字段中包含数据时将接收该电子邮件通知的同一封电子邮件。

So i have created an order form ( http://www.topchoicedata.com/175.php#175 ). 因此,我创建了一个订购表( http://www.topchoicedata.com/175.php#175 )。 Here we have 5 fields the customer would enter with the option for an extra shipping cost. 在这里,我们有5个字段供客户输入,并有一个额外的运输费用选项。 When the user submits, it will take them to a paypal payment page. 当用户提交时,它将带他们到贝宝付款页面。 At this point the persons info from the 5 fields has been inputted into a new row within the table database. 此时,来自5个字段的人员信息已输入到表数据库中的新行中。 When the person progresses further with the payment, the rest of the fields get inputted, all except for one, that field is called "shippingnumber". 当人员进一步付款时,将输入其余字段,除一个字段以外的所有字段都称为“托运号码”。 This is located in an hidden input field for the form mentioned above. 它位于上述表单的隐藏输入字段中。 Below is the html code for the $175 form, with the form action being done in a subfolder named PPPaymentForm/PPPaymentForm.php. 以下是$ 175表单的html代码,该表单操作在名为PPPaymentForm / PPPaymentForm.php的子文件夹中完成。 Take notice of the "shippingorder" input below in the form. 请注意下面表格中的“装运订单”输入。

<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" id="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 chosen)</label>
    <br>
    <br>
    <button name="submit" type="submit" id="submit">Pay Now</button>

    <input type="hidden" name="hdwtablename" id="hdwtablename" value="1">
    <input type="hidden" name="hdwppproductname" id="hdwppproductname" value="Basic Plan $175">
    <input type="hidden" name="hdwppamount" id="hdwppamount" value="175">
    <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="http://www.topchoicedata.com/paymentmadethanks.php">
    <input type="hidden" name="hdwemail" id="hdwemail" value="mauriceflopez+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="$175">
    <input type="hidden" name="shippingchoosen" id="shippingchoosen" value="">
    <input type="hidden" name="shippingnumber" id="shippingnumber" value=""> -----**TAKE NOTICE HERE**
  </form>

Below is a link to a picture of my backend when the customers info is saved after submitting their credentials in the 175 form(Info collected at this point is only for form submission and not paypal info). 下面是指向我的后端的图片的链接,当在175表单中提交其凭据后保存了客户信息时,我的后端信息(此时收集的信息仅用于表单提交,而不适用于Paypal信息)。

Backend with customer info from database 后端包含数据库中的客户信息

As you can see, the person submitted his email("thisisatestemail2016@gmail.com) in the form, and is now in the row, at this point the shippingorder field is empty which is what i want. I now want to fill the "shipping order" field with info, which would then trigger an email to the person's email in that row. I wrote some code hoping that it would work, and placed it at the bottom of the PPPaymentForm/PPPaymentForm.php file, but nothing is working. Below is the code i added to the bottom of the PPPaymentForm.php, with section 2 being the section where i was trying to send an email if the shippingorder field had data put into it. Im guessing i may need some sort of update script in the php, but this is where i am lost 如您所见,此人以表格的形式提交了他的电子邮件(“ thisisatestemail2016@gmail.com),现在已在行中,这时我想要的是shippingorder字段为空。我现在想填写“带有信息的“运输订单”字段,该字段随后会触发该行中该人的电子邮件。我编写了一些代码,希望它能起作用,并将其放在PPPaymentForm / PPPaymentForm.php文件的底部,但没有任何作用。下面是我添加到PPPaymentForm.php底部的代码,第2部分是如果shippingorder字段中有数据的地方,我试图发送电子邮件的部分。我想我可能需要某种更新脚本在PHP中,但这是我迷路的地方

Any help would be greatly greatly appreciated. 任何帮助将不胜感激。

<?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     
*/

$results = mysql_query("SELECT shippingnumber FROM topchoiceform WHERE email=$email");
if(mysqli_num_rows($result) >0){
    $row = mysqli_fetch_assoc($result);
    if ($_POST['shippingnumber']==$row['shippingnumber']) {

       $email = $_POST['email'];
       $subject = "Product has been shipped";
       $message='Your product has been shipped';

       foreach($email as $email){
        mail($email,$subject, $message);
       }
    }

}




/*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";

    }

?>

Why not just send the email when the shipping number is updated? 为什么不只在更新运输编号时发送电子邮件?

// In the script where you update the shippingnumber
$email = $_POST['email'];
$shippingnumber = $_POST['shippingnumber'];

mysql_query("UPDATE topchoiceform SET shippingnumber = '$shippingnumber' WHERE email = '$email'");
$subject = "Product has been shipped";
$message='Your product has been shipped';
mail($email,$subject, $message);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 php表单发送到在电子邮件字段中输入的电子邮件 - php form send to email inputted in email field Laravel:发送包含输入数据的电子邮件 - Laravel: Send Email with Inputted Data 在WooCommerce中应用特定优惠券代码时发送电子邮件通知 - Send an email notification when a specific coupon code is applied in WooCommerce 当在 WooCommerce 中应用特定优惠券代码时,向客户发送 email 通知 - Send an email notification to customer when a specific coupon code is applied in WooCommerce 更新时的Google Forms电子邮件通知 - Google Forms Email Notification When Updated 发送 email 到 $row_data['email'] - Send an email to $row_data['email'] 如何在mysql数据库中更新值时自动发送电子邮件 - how to send email automatically when a value is updated in mysql database 使用email频道时,如何使用Notifier发送内容为HTML的通知? - How to send the notification as content as HTML with Notifier when using the email channel? WordPress-页面加载后如何发送电子邮件通知? - Wordpress - How to send an email notification when page is loaded? 如何将电子邮件发送到在while循环中生成的具有特定行信息的电子邮件? - How to send email to emails generated in while loop with specific row information?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM