2013-04-04 24 views
0

我已經糾正和清理了以前的代碼,, PHP和HTML .. 我會在最後一行解析錯誤.. 我不知道什麼是錯.. 也,網站讓我再補充無用的文字對於後 所有的反應表示讚賞。 感謝名單上最後一行解析錯誤

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
<title>Untitled Document</title> 
</head> 

<body> 

<?php 
if(isset($_POST['email'])) { 

    // EDIT THE 2 LINES BELOW AS REQUIRED 
    $email_to = 'xxx.com, '; 
    $email_subject = "xxx Questons"; 

    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['email']) ||  
     !isset($_POST['comments'])) 
    { 
     died('We are sorry, but there appears to be a problem with the form you submitted.');  
    } 

    $name = $_POST['name']; // not required 


    $email_from = $_POST['email']; // 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(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 .= "Name: ".clean_string($name)."\n"; 

    $email_message .= "Email: ".clean_string($email_from)."\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); 
?> 

<!--include your own success html here --> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html> 

<head> 

<meta http-equiv="Refresh" content="10; URL=xxxx"> 
<title>xxx xxcx xxx</title> 
<meta http-equiv="Content-Language" content="en-us" /> 
    <meta http-equiv="imagetoolbar" content="no" /> 

     <meta name="MSSmartTagsPreventParsing" content="true" /> 

    <meta name="description" content="xxxsxxx xxx. " /> 

    <meta name="keywords" content="orchids, xxx, Orchid judging, xxx" /><style type="text/css" media="all">@import "css/master.css";</style> 
</head> 
<body> 
<p><div id="textbox"><br><br> 

<center><h1>Thank you for contacting us. <br /> 
We will be in touch with you very soon.</h1> 

<br><br> 

Please wait 10 seconds and you will be transferred to the next page or <a href=http:xxxindex.html><font color="#0000ff">click here</font></a> to go now!</center> 

<p><center>Please visit our website <a href="xxx"><i>www.</i></a> to learn more <br /> 
    about the xxx</center> 
<p>&nbsp;</p> 
</div>  
</div> 
</div> 

</body> 
</html> 
</body> 
</html> 
+0

你的最後一個行重複''。這是一個複製粘貼錯誤? – Grambot 2013-04-04 15:53:28

+0

看起來你還沒有關閉第11行的if語句。 – xenon 2013-04-04 15:55:04

+1

@xenon Exactamente – 2013-04-04 15:55:51

回答

4

你缺少一個右}在PHP代碼

原來開{從該行即將結束:

if(isset($_POST['email'])) { 

所以,mail功能後, ,加另一個}

+0

非常感謝你..修復它..我不知道爲什麼錯誤沒有告訴我正確的位置的錯誤.. PLUS它不列出失蹤的請求' d信息..你知道什麼是錯的嗎? than than – user2229604 2013-04-04 16:17:46

+0

@ user2229604我知道什麼是錯?這應該解決這個問題.. – 2013-04-04 16:18:44

+0

'好吧..確切沒有解決這個問題..我會發布差異概率.. – user2229604 2013-04-04 19:52:03

1

更改:

// 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); 

// 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); 
} // 
+0

當我這樣做,它說意外的'}'...它只讓我接受一個。 。謝謝,謝謝 – user2229604 2013-04-04 19:58:39