2016-04-12 76 views
0

对不起,听起来像一个破纪录,我上周发布了类似的问题,并已经取得了一些不错的进展输入,但我需要走更进一步。如何电子邮件触发通知发送到特定的电子邮件行内时更新域/数据

所以我一直拉我的头发,这需要一些指导和帮助。简而言之,我需要能够在数据库或自定义后端填入一个空白字段(字段称为“shippingnumber”),然后它会触发同一行中的个人电子邮件的自定义电子邮件通知。这是我到目前为止。我们将使用电子邮件“[email protected]”为例。这是该人员将提交到下面的表单中的电子邮件,也是同一封电子邮件,当该字段“shippingnumber”中包含数据时,该电子邮件将收到电子邮件通知。

因此,我已创建了一个定单表格(http://www.topchoicedata.com/175.php#175)。在这里,我们有5个领域的客户将输入一个额外的运输成本的选项。当用户提交时,它将把他们带到一个贝宝付款页面。此时,来自5个字段的个人信息已被输入到表数据库内的新行中。当该人进一步付款时,其余的字段被输入,除了一个之外,该字段被称为“shippingnumber”。这位于上述表单的隐藏输入字段中。以下是$ 175表单的html代码,表单操作在名为PPPaymentForm/PPPaymentForm.php的子文件夹中完成。注意下面表格中的“运输订单”输入。

<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> 

下面是我的后台的照片时,客户信息是在175的形式提交他们的凭据后保存的链接(信息收集在这一点上是仅适用于表单提交,而不是贝宝信息)。

Backend with customer info from database

正如你所看到的,人的形式提交自己的电子邮件(“[email protected]),现在该行中,在这一点上shippingorder字段为空而这正是我我现在想用信息填写“发货订单”字段,然后在该行中触发一封电子邮件给该人的电子邮件,我写了一些代码,希望它可以工作,并将其放置在PPPaymentForm/PPPaymentForm.php文件,但没有任何工作,下面是我添加到PPPaymentForm.php底部的代码,第2部分是我试图发送电子邮件的部分,如果shippingorder字段有数据放入它。猜测我可能需要在PHP中的某种更新脚本,但这是我失去的地方t

任何帮助将非常感激。

<?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"; 

    } 

?> 

回答

1

为什么不在发送邮件时发送邮件?

// 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); 
相关问题