繁体   English   中英

html表单的后端

[英]Backend of html form

我在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

尝试更改此行:

died('We are sorry, but ...

提示:

die('We are sorry, but you cannot spell

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM