0

我在我的 html 表单的后端需要帮助。我想要做的当然是获取用户在包含实际表单的 html 页面上输入的信息。该页面正在解释 php 中的数据,我希望它向自己发送一封包含收集到的信息的电子邮件。我已经采取了所有安全措施,据我所知,它应该可以工作。但由于某种原因,它不是......它在第 20 行给了我一个语法错误。我将提供收集用户信息的 php 文件的完整代码。我认为我不需要发布实际的 html 表单,但如果需要,我也会发布。谢谢您的帮助。

 <?php
  require_once('recaptchalib.php');
  $privatekey = "aFakePrivateKey";
  $resp = recaptcha_check_answer ($privatekey,
                                $_SERVER["REMOTE_ADDR"],
                                $_POST["recaptcha_challenge_field"],
                                $_POST["recaptcha_response_field"]);

  if (!$resp->is_valid) {
    // What happens when the CAPTCHA was entered incorrectly
    die ("The CAPTCHA wasn't entered correctly. Go back and try it again.");
  } else {





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

    $email_to = "blank@blank.com";
    $email_subject = "Customer Support";


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

    $type = $_POST['inquire']; // required
    $email_from = $_POST['eadrr']; // required
    $comments = $_POST['mess']; // 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 />';
  }
  if(strlen($comments) < 5) {
    $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 .= "Email: ".clean_string($email_from)."\n";
    $email_message .= "Type of Inquiry: ".clean_string($type)."\n";
    $email_message .= "Message: ".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);  

echo 'Thank you for your message. Based on the type of inquiry we may respond within a week.';

}


  }
?>

错误信息:

解析错误:语法错误,第 20 行 /home/a6675286/public_html/verify.php 中的意外 T_VARIABLE

4

1 回答 1

0

尝试更改此行:

died('We are sorry, but ...

tp这个:

die('We are sorry, but you cannot spell

当然,除非您实际上编写了一个名为 dead() 的函数...

于 2012-07-23T15:12:56.743 回答