简体   繁体   English

html表单的后端

[英]Backend of html form

I need help on the backend of my html form. 我在HTML表单的后端需要帮助。 What I want to do is of course take the information that the user inputted on the html page that included the actual form. 我要做的当然是获取用户在html页面上输入的包含实际表单的信息。 The page is interpreting the data in php and I would like it to send an email to myself with the information gathered. 该页面正在解释php中的数据,我希望它向我发送一封电子邮件,其中包含收集的信息。 I have all of the security measures in place and as far as I can tell ,it should work. 我已经采取了所有安全措施,据我所知,它应该起作用。 But for some reason it is not...It is giving me a syntax error on line 20. I will provide the full code of the php file that gathers the user information. 但是由于某些原因,它不是...这给了我第20行的语法错误。我将提供收集用户信息的php文件的完整代码。 I don't think I need to post the actual html form, but if it is requested I will post that as well. 我认为我不需要发布实际的html表单,但是如果需要,我也将发布它。 Thanks for the help. 谢谢您的帮助。

 <?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.';

}


  }
?>

Error Message: 错误信息:

Parse error: syntax error, unexpected T_VARIABLE in /home/a6675286/public_html/verify.php on line 20 解析错误:语法错误,第20行的/home/a6675286/public_html/verify.php中出现意外的T_VARIABLE

Try changing this line: 尝试更改此行:

died('We are sorry, but ...

tp this: 提示:

die('We are sorry, but you cannot spell

Unless of course you actually wrote a function called died()... 当然,除非您实际上编写了一个名为die()的函数...

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

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