php发邮件表格空白提交
问题描述:
我希望你能帮助,所以我不去灰色。php发邮件表格空白提交
我的表单提交后只显示空白屏幕,它只有当我添加选择选项。当我输入详细信息并将其提交到quote.php但显示空白页面时。
我会感激你的帮助:)
<?php
if(isset($_POST['email'])) {
$email_to = "[email protected]";
$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._%-][email protected][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>
启用错误报告并从那里开始调试(放置'error_reporting(E_ALL); ini_set(“display_errors”,1);'在页面顶部,在第一个 Epodax
在我的错误文件中得到这个 [16-Mar-2017 10:42:30 UTC] PHP解析错误:语法错误,意想不到的'死'(T_EXIT),期待'('在/home/wwwbrigh/public_html/dev/quote.php在线18 [16-Mar-2017 10:42:35 UTC] PHP解析错误:语法错误,意想不到的'死'(T_EXIT),期待'('in'/'在/home/wwwbrigh/public_html/dev/quote.php在线18 [16-Mar-2017 10:50:12 UTC] PHP解析错误:语法错误,意想不到的'死'(T_EXIT),期待'('在/ home/www.brigh/public_html/dev/quote.php在线21 – user1347007