代码之家  ›  专栏  ›  技术社区  ›  Crashy

发送PHP确认电子邮件联系人表单而不使用action=“”

  •  0
  • Crashy  · 技术社区  · 7 年前

    我需要替换一个网站上的联系人表单,我以前在以前的联系人表单中使用通过PHP发送的确认电子邮件,因为属性操作是空的,所以我可以将PHP代码保存在同一页上。这是我以前的联系方式:

    <form action="" method="POST">
    
        <input type=hidden name="oid" value="00Db0000000IeRo">
        <input type=hidden name="retURL" value="http://business.mytaxi.ie/thankyou.php">
    
        <input id="email" maxlength="80" name="email" size="20" required="" type="email" value="" oninvalid="InvalidMsg(this);" oninput="InvalidMsg(this);" placeholder="email"/>
        <a href="" class="bannerbutsub" title="get started for free.">get started for free.</a>
        <input type="submit" name="submit" value="Register Interest" title="Register Interest" class="bannerbutsub">
    
    </form>
    

    if($_POST['email']){
        $q = "INSERT INTO entries (email, datetime) VALUES ('".mysql_real_escape_string($_POST['email'])."',now())";
        $r = mysql_query($q) or die(mysql_error());
    
    
    // sending confirmation email
    
    $to = $_POST['email'];
    $subject = 'Registration Confirmation';
    $from = 'ireland.business@mytaxi.com';
    
    // To send HTML mail, the Content-type header must be set
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    
    // Create email headers
    $headers .= 'From: '.$from."\r\n".
        'Reply-To: '.$from."\r\n" .
        'X-Mailer: PHP/' . phpversion();
    
    // Compose a simple HTML email message
    $message = '<html><body>';
    $message .= '<p>Hi there,</p>';
    $message .= '<p>Thanks for registering your interest in mytaxi | Business.</p>';
    $message .= '<p>Our corporate service offers individuals and organisations complete visibility on taxi spend with on-demand automated reporting and as Ireland’s largest and only nationwide network, wait times are as low as 4 minutes.  There’s options available to suit everyone: from enterprise organisations to SME\'s to individuals. </p>';
    $message .= '<p><a href="https://www.youtube.com/watch?v=jGDxs9Xf0jA" target="_new"><img src="http://business.mytaxi.ie/youtube.jpg"></a></p>';
    $message .= '<p>A member of our corporate team will be touch with you shortly.</p>';
    $message .= '<p>Many Thanks, <br>mytaxi | Business Team</p>';
    $message .= '</body></html>';
    // Sending email
    mail($to, $subject, $message, $headers);
    

    工作很顺利,但后来我被要求用一张新的联系表代替

    新的联系方式如下:

                            <form action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="GET">
    
                            <input type=hidden name="oid" value="00Db0000000IeRo">
                            <input type=hidden name="retURL" value="http://business.mytaxi.ie/thankyou.php">
    
                            <input id="email" maxlength="80" name="email" size="20" required="" type="email" value="" oninvalid="InvalidMsg(this);" oninput="InvalidMsg(this);" placeholder="email"/>
    
                            <input type="hidden" id="lead_source" name="lead_source" value="Web" />
    
                            <input type="hidden" id="country" name="country" value="Ireland" />
    
                            <input type="submit" name="submit" value="Register Interest" title="Register Interest" class="bannerbutsub">
    
    
                            </form>
    

    如您所见,在新的联系人表单中,联系人表单的属性Action=“”中有一个URL,因此确认电子邮件不再工作。 我不能去掉价值,因为它是需要的。在用户提交CF后,是否有其他方法保存新的联系人表单并继续发送确认电子邮件?

    1 回复  |  直到 7 年前
        1
  •  0
  •   Leigh Bicknell    7 年前

    理想情况下,确认电子邮件的发送现在需要在以下地址处理: https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8

    这里有很多破烂的方法。。。可以再次清空操作,使其提交到脚本,然后使用curl使脚本将数据重新提交到 然后根据回复发送电子邮件。

    您还可以在表单提交时向脚本发送ajax请求,脚本将处理电子邮件的发送。

    但这两种方法都很老套,最终响应/通知用户表单提交的成功/失败是表单数据提交到的脚本的责任。