我不明白错误但我的联系表格正在运行" mail"脚本,但没有任何POST数据。谁能告诉我它为什么不起作用?
的index.php:
<form id="newsletter-form" class="newsletter_form" action="php/order.php" method="post">
<input id="email_newsletter" required type="text" name="or_name" placeholder="Name*">
<input id="email_newsletter" type="text" name="or_company" placeholder="Company Name">
<input id="email_newsletter" required type="email" name="or_email" placeholder="Email*">
<input id="email_newsletter" type="tel" name="or_tel" placeholder="Phone">
<select id="email_newsletter" required name="or_package">
<option value="" selected disabled>Select Package*</option>
<option value="Starter">Starter - 1 Page Site £49</option>
<option value="Business">Business - 3 Page Site £99</option>
<option value="Premier">Premier - 6 Page Site £179</option>
</select>
<textarea id="email_newsletter" required class="or_tarea" name="or_details" placeholder="Project Details*"></textarea>
<input type="submit" value="SUBMIT!" id="submit-button-newsletter">
</form>
order.php:
<?php
$field_name = $_POST['or_name'];
$field_company = $_POST['or_company'];
$field_email = $_POST['or_email'];
$field_tel = $_POST['or_tel'];
$field_package = $_POST['or_package'];
$field_details = $_POST['or_details'];
$mail_to = 'my@email.com'; //Change to your email
$subject = 'Enquiry from '.$field_name.' ('.$field_company.')'; //Change to your subject
$body_message = 'From: '.$field_name."\n";
$body_message .= 'Company: '.$field_company."\n";
$body_message .= 'E-mail: '.$field_email."\n";
$body_message .= 'Phone: '.$field_tel."\n";
$body_message .= 'Package: '.$field_package."\n";
$body_message .= 'Details: '.$field_details;
$headers = 'From: '.$field_email."\r\n";
$headers .= 'Reply-To: '.$field_email."\r\n";
$mail_status = mail($mail_to, $subject, $body_message, $headers);
?>
当然,电子邮件会发送到我的收件箱。当我填写表格并按发送时,我会收到这封空白电子邮件:
Subject;
Enquiry from ()
Message;
From:
Company:
E-mail:
Phone:
Package:
Details:
答案 0 :(得分:0)
作为第一步,您是否可以将POST变量回显到脚本中以确保它们实际被设置?
echo $field_name = $_POST['or_name'];
答案 1 :(得分:0)
检查正在传递的所有POST变量的值。
echo print_r($_POST,true);
检查您的PHP错误日志,看看是否有任何警告/通知。
无关:您在处理之前是否正在清理用户输入?
答案 2 :(得分:0)
事实证明,尽管HTML和PHP需要清理,但它们根本不是问题。这是一个经过修改的第三方脚本,结果发现有一个附加的JS文件正在过滤POST信息。我修改了它以包含新的表单输入,它工作正常:)