2017-03-16 18 views
-1

私は灰色にならないように助けてくれることを願っています。php send mail form submit on

送信後のフォームには空白の画面しか表示されず、選択オプションを追加すると表示されます。詳細を入力して送信すると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> 
+0

エラー報告を有効にし、そこからデバッグを開始します( 'error_reporting(E_ALL);;あなたのページの一番上にある、最初の '<?php'のすぐ下にある3235 ini_set(" display_errors "、1); – Epodax

+0

これは私のエラーファイル にあります[16-Mar-2017 10:42:30 UTC] PHP構文解析エラー:予期しない 'die'(T_EXIT)、18行目の/home/wwwbrigh/public_html/dev/quote.phpに '('があります) [16-Mar-2017 10:42:35 UTC] PHP Parseエラー:予期しない 'die'(T_EXIT)、予期していた '(' /home/wwwbrigh/public_html/dev/quote.phpの18行目) [16-Mar-2017 10:50:12 UTC] PHP Parse error :構文エラー、予期しない 'die'(T_EXIT)、 '(' /home/wwwbrigh/public_html/dev/quote.php 21行目で) – user1347007

答えて

0

使用)(死ぬ代わりに死亡した

を見逃しているか確認してください。

+0

ちょうど同じ空白の画面を試しました:( – user1347007