2017-03-16 3 views
-1

Ich hoffe du kannst helfen damit ich nicht grauer werde.php send mail form leer beim einreichen

Mein Formular nach dem Senden zeigt nur leeren Bildschirm und es ist nur, wenn ich die Auswahloption hinzufügen. Wenn ich Details eingebe und abschicke geht es zu quote.php aber zeigt leere Seite an.

Ich würde schätzen Ihre Hilfe :)

<?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 //////////// 

Ich habe die meisten wahrscheinlich etwas klein verpasst :(

<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

Aktivieren Sie die Fehlerberichterstattung und starten Sie das Debuggen von dort aus. (Platzieren Sie error_reporting (E_ALL); ini_set ("display_errors", 1); 'am Anfang der Seite, direkt unter dem ersten' Epodax

+0

In meiner Fehlerdatei [16-Mär-2017 10:42:30 UTC] PHP Parse-Fehler: Syntaxfehler, unerwarteter 'Die' (T_EXIT), erwartet '(' in /home/wwwbrigh/public_html/dev/quote.php on line 18 [16-Mar-2017 10:42:35 UTC] PHP Parse Fehler: Syntaxfehler, unerwarteter 'Die' (T_EXIT), erwartet '(' in /home/wwwbrigh/public_html/dev/quote.php on line 18 [16-Mär-2017 10:50:12 UTC] PHP Parse Fehler : syntax error, unerwartete 'die' (T_EXIT), erwartet '(' in /home/wwwbrigh/public_html/dev/quote.php on line 21 – user1347007

Antwort

0

Verwenden statt starb die()

Bitte überprüfen.

+0

Habe gerade noch den gleichen leeren Bildschirm versucht :( – user1347007