带有Action元素的表单不会触发电子邮件

时间:2016-10-24 15:39:09

标签: html forms email input action

我有一个对第三方网址采取行动的表单,当动作元素添加到表单时,它不会发送电子邮件,否则如果我们删除action =“”它会完美地发送电子邮件。

<form id="quote-forms" method="post" accept-charset="UTF-8" action="https://www.aweber.com/scripts/addlead.pl">   
            <div style="display: none;">
            <input type="hidden" name="meta_web_form_id" value="1776486715" />
            <input type="hidden" name="meta_split_id" value="" />
            <input type="hidden" name="listname" value="awlist4465692" />
            <input type="hidden" name="redirect" value="http://www.prioritymoving.com/quotes-form" id="redirect_740f29515aa8c7026603cd8e75a7bdb1" />
            <input type="hidden" name="meta_adtracking" value="Quote_Form_Priority_Moving" />
            <input type="hidden" name="meta_message" value="1" />
            <input type="hidden" name="meta_tooltip" value="custom mdate (awf_month)||preSelectedHeadingSelected,,custom mdate (awf_day)||preSelectedHeadingSelected,,custom mdate (awf_year)||preSelectedHeadingSelected,,custom dstate||Pick a state,,custom ostate||Pick a state" />
            </div>
           <label >Origin City</label>
             <input name="ocity" class="form-control-field" value="<?php echo $info[0] ; ?>"  placeholder="City" type="text">
             <label >Origin State</label>
             <input name="ostate" class="form-control-field" value="<?php echo $info[1] ; ?>"  placeholder="State" type="text">
              <input name="ozip" class="form-control-field" value="<?php echo $info[2] ; ?>"  placeholder="Zip Code" type="text">
             <input name="quote-forms"  value="Get Quote"   type="submit">
        </div>
      </div>
  </form>

这就是我在提交按钮的帖子上发送电子邮件的方式:你能否指导我如何解决这个问题,即行动在那里,它也发送电子邮件..

<?php 
if(isset($_POST['quote-forms'])){

$oCity          = $_POST["ocity"];
$iZip           = $_POST["ozip"];
$oState         = $_POST["ostate"];

$to = 'shoaibswl123@gmail.com';

$subject = 'Quote Request From '. $fName ;

$message = '<html><body>'; 

$message = '<div style="background:#CEE4ED; padding:10px;>';
$message = '<div style="margin-left:30px;">';


$message .= "<b>Hi Admin,</b>";
$message .= 'You have received a new quote from the site with the following information';


$message .= "<b>Origin City: </b>" .$oCity;
$message .= "<br />";
$message .= "<b>Origin Zip: </b>" . $iZip; 
$message .= "<br />";
$message .= "<b>Origin State: </b>" . $oState;
$message .= "<br />";

$message .= "<p>Thank you.</p>";

$message .= "</div></div>";

$message .= "</body></html>";

$headers  = 'MIME-Version: 1.0' . "\r\n";

$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";

$headers .= 'From: '.$pEmail.'' . "\r\n";


 if(wp_mail($to, $subject, $message, $headers)){

  echo "<div class='success-message'>Message Has Been Sent Successfully..!</div>";

  }else{

   echo "<div class='success-message'>There is an error while sending message..!</div>";
 }


  } ?>

请帮帮我... 谢谢!

1 个答案:

答案 0 :(得分:0)

在回复我的评论后,一切都很清楚:

  • 没有à定义action,默认的是当前页面,因此您可以回想起原始脚本并执行与邮件相关的PHP部分

  • 如你所定义的那样action,引用的脚本被称为......原来的脚本不是!

您应该做的是将与邮件相关的PHP部分放在addlead.pl脚本中。
或者,如果不那么容易(我甚至不知道.pl指的是什么),你可能会:

  • 将与邮件相关的PHP部分保留在原始脚本中
  • 保持<form>action
  • 在这部分中,就在整个块的右括号之前,添加一个重定向,如header('Location: ...the relevant url...');