1

我正在努力将 reCAPTCHA 实施到联系表格中,但我无法弄清楚我做错了什么。reCAPTCHA 字段未显示在页面上,它已删除我的 php 页脚包括以及提交/重置按钮。另外,我不确定我是否在我的 send-mail.php 文件中正确地进行了验证。

联系表

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<head>
<link rel="icon" href="/bp/images/favicon.ico" type="image/x-icon" />
<title>San Diego Ministries | 3223232323.com</title>

<meta name="keywords" content="Jesus Christ, Ministries, Salvation, Church San Diego, Small Group, Christian" />
<meta name="description" content="... is a San Diego based Ministry." />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

 <script type="text/javascript">
 var RecaptchaOptions = {
    theme : 'clean'
 };
 </script>



<!--/ CSS-->

<!--/ Events CSS-->
<link rel="stylesheet" href="/bp/css/prayer-request.css" type="text/css" media="screen" />



</head>

<body>

<?php include 'header.php'; ?>



<!--/ Title-->

<div class="prayer-title"><img src="/bp/images/prayer-title.jpg"></img></div>



<!--/ Prayer Request Description-->


<div id="prayer-desc">

<p>
If you have a prayer request or question for one of our pastors, fill out the form below and one of our pastors will receive it and personally pray for you.
Thanks for sharing and giving us the opportunity to pray for you!
</p>

<p>
<b>Please note:</b> All contact fields are optional and your prayer requests are kept strictly confidential.
</p>

</div>



<!--/ Show Prayer Request Form-->

<div id="prayer-form">


<form name="prayer-form" action="send-mail.php" method="POST">

<label for="field_name">Name:</label> <input type="text" id="field_name" name="sender_name" placeholder="First Name, Last Name"> 
<br>
<label for="field_email">Email:</label> <input type="text" id="field_email" name="sender_email" placeholder="example@domain.com">
<br>
<label for="field_phone">Phone:</label> <input type="text" id="field_phone" name="sender_phone" placeholder="(444) 444-4444">
<br>
<label for="field_message">Prayer Request:</label>

<textarea id="field_message" name="sender_message" placeholder="How can we pray for you?"></textarea>
<br>

    <?php
          require_once('/bp/recaptchalib.php');
          $publickey = "********************Po3UtfoqR1AzBk";
          echo recaptcha_get_html($publickey);
        ?>

<br>        
<input type="submit" name="send_message" value="Submit"> <input type="reset" value="Reset">

</form>

</div>


<div class="bottom-block"><img src="/bp/images/white-block.jpg"></img></div>        


</body>
</html>

<?php include 'footer.php'; ?>

发送邮件.php

  <?php
  require_once('/bp/recaptchalib.php');
  $privatekey = "*******************yfYWTRW0hG7CrJ8hItb";
  $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 reCAPTCHA wasn't entered correctly. Go back and try it again." .
         "(reCAPTCHA said: " . $resp->error . ")");
  } else {
    // Your code here to handle a successful verification
  }
  ?>



<?php     

$mail_to = "hel344323@gmail.com"; // specify your email here


// Assigning data from the $_POST array to variables

$name = $_POST['sender_name'];

$mail_from = $_POST['sender_email'];

$phone = $_POST['sender_phone'];

$web = $_POST['sender_web'];

$company = $_POST['sender_company'];

$addy = $_POST['sender_addy'];

$message = $_POST['sender_message'];


// Construct email subject

$subject = 'Email Web Prayer Request from ' . $name;


// Construct email body

$body_message = 'From: ' . $name . "\r\n";

$body_message .= 'E-mail: ' . $mail_from . "\r\n";

$body_message .= 'Phone: ' . $phone . "\r\n";

$body_message .= 'Prayer Request: ' . $message;



// Construct email headers

$headers = 'From: ' . $name . "\r\n";

$headers .= 'Reply-To: ' . $mail_from . "\r\n";

$mail_sent = mail($mail_to, $subject, $body_message, $headers);


if ($mail_sent == true){ ?>

<script language="javascript" type="text/javascript">
alert('Your prayer request has been submitted - thank you.');

window.location = 'prayer-request.php';

</script>

<?php } else { ?>

<script language="javascript" type="text/javascript">
alert('Message not sent. Please, notify the site administrator admin@lsdlsdection.com');

window.location = 'prayer-request.php';
</script>

<?php

    }

?>

链接到网站

4

2 回答 2

2

您的 PHP 代码中有错误。可能是这一行的致命错误,

require_once('/bp/recaptchalib.php');

我怀疑文件路径recaptchalib.php是错误的。我建议打开 PHP 错误并重试。

您可以通过在文件开头添加此 PHP 代码来打开错误,

ini_set('display_errors', TRUE);

我希望这对现在有所帮助。

于 2013-03-16T16:26:53.917 回答
0

检查您的错误日志。从它的声音来看,您的脚本正在触发一个致命错误(很可能是由于 reCAPTCHA 库的路径不正确),这会停止脚本执行,因此您的站点的页脚不再显示。

于 2013-03-16T16:31:58.423 回答