php发送邮件表单提交时为空
我希望你能帮我,这样我就不会变灰了 提交后的表单只显示空白屏幕,只有在添加选择选项时才会显示。当我输入详细信息并提交时,它会转到quote.php,但会显示空白页面 我将感谢您的帮助:)php发送邮件表单提交时为空,php,forms,sendmail,Php,Forms,Sendmail,我希望你能帮我,这样我就不会变灰了 提交后的表单只显示空白屏幕,只有在添加选择选项时才会显示。当我输入详细信息并提交时,它会转到quote.php,但会显示空白页面 我将感谢您的帮助:) 我的主要html表单代码如下//////////// 我很可能错过了一些小东西:( 姓名: 电邮: 电话: 草坪和树篱 围栏、铺板和板条 花园改造 花园维护 树木工程 病虫害防治 花园清理 信息: 使用骰子代替骰子() 请检查。启用错误报告并从那里开始调试。(将错误报告(E_ALL);ini_set(“d
我的主要html表单代码如下////////////
我很可能错过了一些小东西:(
姓名:
电邮:
电话:
草坪和树篱
围栏、铺板和板条
花园改造
花园维护
树木工程
病虫害防治
花园清理
信息:
使用骰子代替骰子()
请检查。启用错误报告并从那里开始调试。(将
错误报告(E_ALL);ini_set(“display_errors”,1);
放在页面顶部,第一个的正下方,在我的错误文件[16-Mar-2017 10:42:30 UTC]PHP解析错误:语法错误,意外的'die'(T_EXIT),期望'('in/home/wwwbrigh/public_html/dev/quote.php第18行[2017年3月16日10:42:35 UTC]php解析错误:语法错误,意外的'die'(T_EXIT),预期'('in/home/wwwbrigh/public_html/dev/quote.php第18行[2017年3月16日10:50:12 UTC]php解析错误:语法错误,意外的'die'(T_EXIT),预期'('in/home/wwwbrigh/public_html/dev/quote.php第21行
<?php
if(isset($_POST['email'])) {
$email_to = "rbsteele68@gmail.com";
$email_subject = "Enquiry from Bright gardens website";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['first_name']) ||
!isset($_POST['last_name']) ||
!isset($_POST['email']) ||
!isset($_POST['service']) ||
!isset($_POST['telephone']) ||
!isset($_POST['comments'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$first_name = $_POST['first_name']; // required
$last_name = $_POST['last_name']; // required
$email_from = $_POST['email']; // required
$service = $_POST['service']; // not required
$telephone = $_POST['telephone']; // not required
$comments = $_POST['comments']; // required
$error_message = "";
$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$first_name)) {
$error_message .= 'The First Name you entered does not appear to be valid.<br />';
}
if(!preg_match($string_exp,$last_name)) {
$error_message .= 'The Last Name you entered does not appear to be valid.<br />';
}
if(strlen($comments) < 2) {
$error_message .= 'The Comments you entered do not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "First Name: ".clean_string($first_name)."\n";
$email_message .= "Last Name: ".clean_string($last_name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Service: ".clean_string($service)."\n";
$email_message .= "Telephone: ".clean_string($telephone)."\n";
$email_message .= "Comments: ".clean_string($comments)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
My main html form code is below ////////////
<form id="contact-form" method="post" action="quote.php">
<div class="messages"></div>
<div class="form-group request_group">
<label>Name:</label>
<input id="form_name" type="text" name="first_name" class="form-control">
<div class="help-block with-errors"></div>
</div>
<div class="form-group request_group">
<label>Email:</label>
<input id="form_lastname" type="text" name="last_name" class="form-control">
<div class="help-block with-errors"></div>
</div>
<div class="form-group request_group">
<label>Phone:</label>
<input id="form_text" type="text" name="telephone" class="form-control">
<div class="help-block with-errors"></div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group request_group">
<select name="service" data-bv-field="state" class="form-control quick_form_control selectpicker">
<option value="Lawns & hedging">Lawns & hedging</option>
<option value="Fencing, decking & slabbing">Fencing, decking & slabbing</option>
<option value="Garden makeovers">Garden makeovers</option>
<option value="Garden maintenance">Garden maintenance</option>
<option value="Tree work">Tree work</option>
<option value="Pest control">Pest control</option>
<option value="Garden clearing & clearup">Garden clearing & clearup</option>
</select>
<div class="help-block with-errors"></div>
</div>
</div>
</div>
<div class="form-group request_group">
<label>Message:</label>
<textarea id="var4form_mess1" name="comments" class="form-control"></textarea>
<div class="help-block with-errors"></div>
</div>
<div class="form-group request_group">
<label></label>
<input type="submit" value="Get a quote" class="btn submit_now get-a-quote_btn">
</div>
</form>