Google ReCaptcha Возврат неверного-captcha-sol - PullRequest
0 голосов
/ 31 января 2020

У меня проблемы с моей контактной формой, потому что она возвращает ReCAPTCHA не было введено правильно. Go вернитесь и попробуйте снова. (ReCAPTCHA сказал: invalid-captcha-sol), даже когда я отвечаю правильно. У меня совершенно нет идей, и я пытался следовать руководствам на этом форуме и других, и мне не повезло.

Вот мой PHP

<?php
  require_once('recaptchalib.php');
  $privatekey = "Private key here";
  $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
// Put contacting email here
$php_main_email = "my email here";

//Fetching Values from URL
$php_name = $_POST['ajax_name'];
$php_email = $_POST['ajax_email'];
$php_message = $_POST['ajax_message'];



//Sanitizing email
$php_email = filter_var($php_email, FILTER_SANITIZE_EMAIL);


//After sanitization Validation is performed
if (filter_var($php_email, FILTER_VALIDATE_EMAIL)) {


        $php_subject = "Message from contact form";

        // To send HTML mail, the Content-type header must be set
        $php_headers = 'MIME-Version: 1.0' . "\r\n";
        $php_headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
        $php_headers .= 'From:' . $php_email. "\r\n"; // Sender's Email

        $php_template = '<div style="padding:50px;">A Message has been recived from ' . $php_name . ',<br/>'
        . 'The message is as follows...<br/><br/>'
        . '<strong style="color:#f00a77;">Name:</strong>  ' . $php_name . '<br/>'
        . '<strong style="color:#f00a77;">Email:</strong>  ' . $php_email . '<br/>'
        . '<strong style="color:#f00a77;">Message:</strong>  ' . $php_message . '<br/><br/>'
        . 'This email was sent from the contact form.'
        . '<br/>'
        . 'To send a reply, please reply to this email .</div>';
        $php_sendmessage = "<div style=\"background-color:#f5f5f5; color:#333;\">" . $php_template . "</div>";

        // message lines should not exceed 70 characters (PHP rule), so wrap it
        $php_sendmessage = wordwrap($php_sendmessage, 70);

        // Send mail by PHP Mail Function
        mail($php_main_email, $php_subject, $php_sendmessage, $php_headers);
        echo "";

} else {
    echo "<span class='contact_error'>* Invalid email *</span>";
}


  }
  ?>

, а вот контактный раздел моего site

<form action="/" method="post" class="contact_form" id="contact_form">
    <div class="returnmessage" data-success="Your message has been received, We will contact you soon."></div>
    <div class="empty_notice"><span>Please Fill Required Fields</span></div>
    <div class="wrap wow fadeIn" data-wow-duration="0.6s">
        <input id="name" type="text" placeholder="Your Name">
    </div>
    <div class="wrap wow fadeIn" data-wow-duration="0.6s" data-wow-delay="0.2s">
        <input id="email" type="text" placeholder="Your Email">
    </div>
    <div class="wrap wow fadeIn" data-wow-duration="0.6s" data-wow-delay="0.4s">
        <textarea id="message" placeholder="Your Message"></textarea>
    </div>
    <div class="wrap wow fadeIn" data-wow-duration="0.6s" data-wow-delay="0.6s">
        <center>      <div class="g-recaptcha" data-sitekey="6Lei_dMUAAAAAMDKnRU7w9Z7z0eQG-cB16JEgqwk"></div> </center>
    </div>

    <div class="marox_tm_button wow fadeIn" data-wow-duration="0.6s" data-wow-delay="0.8s">
        <a id="send_message" href="#">Send Message</a>
    </div>
</form>

Буду очень признателен за любую помощь, которая может быть оказана. Спасибо Джейк

...