解析最后一行的错误

时间:2013-04-04 15:51:58

标签: php html

我已经纠正并清理了以前的代码,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._%-]+@[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>

2 个答案:

答案 0 :(得分:4)

您错过了PHP代码末尾的结束}

原始开场{来自这一行:

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

因此,在mail功能之后,添加另一个}

答案 1 :(得分: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);  
} //