Search the Community
Showing results for tags 'recaptcha php error'.
-
Hi All, Very new to PHP so I wonder if you can help. I have set up a form with Recaptcha on it. The form posts the information on the front page (which works). The only problem is that I want the code to send the user back to the home page. <?php require_once('recaptchalib.php'); $privatekey = "6LfxZN8SAAAAAIxozrSnTxTgrAljrQlM0R7k8yEQ"; $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 . ")"); } elseif { // Your code here to handle a successful verification ($_POST['submit']){ $connect = mysql_connect("localhost","hautopsy_root","Kings!123") or die ("couldnt connect"); $db = mysql_select_db("hautopsy_netconfess") or die ("database error"); $nc='nc'; $name = strip_tags($_POST['name']); $confession = ($_POST['confession']); $datetime = date ("Y:m:d:H:m:s"); $query = mysql_query("insert into nc (name, confession, datetime) values('$_POST[name]', '$_POST[confession]', '$datetime')") or die ("failed to insert"); header('Location: http://www.example.com/'); }else{ header("Location: index.php"); } } ?> I am using header("Location: index.php"); but it just seems to be staying on the same page. Thanks
-
Hello I am receiving a huge amount of spam emails, now I am trying to implement Google Recaptcha V3 in my custom PHP From, I implemented all the steps for G-Recaptcha, but I receive error invalid-input-secret And I am sure that the secret code shout be copied right I added the below to the head tag <script src="https://www.google.com/recaptcha/api.js?render=6LfyPF0pAAAAAHLxp3315RTN7jrRvBe6kLdHGAiT"></script> <script> grecaptcha.ready(function() { grecaptcha.execute('6LfyPF0pAAAAAHLxp3315RTN7jrRvBe6kLdHGAiT', {action: 'submit'}).then(function(token) { let recaptchaResponse = document.getElementById("recaptchaResponse"); console.log(recaptchaResponse); recaptchaResponse.value = token; }); }); </script> Then added hidden input before the submit button in the Form <input type="hidden" name="recaptcha_response" id="recaptchaResponse"> <input class="contactInput no-border cursorPointer buttonStyle" name="submitContact" value="Submit" type="submit"> And finally, I implemented the PHP code if(isset($_POST['submitContact']) && $_SERVER['REQUEST_METHOD'] == 'POST'){ $recaptcha_url = 'https://www.google.com/recaptcha/api/siteverify'; $recaptcha_secret = '6LfyPF0pAAAAAEsS5lfN_WL3wKHh1XfGo0oE_PYU'; $recaptcha_response = $_POST['recaptcha_response']; $recaptcha = file_get_contents($recaptcha_url."?secret=".$recaptcha_secret."?response=".$recaptcha_response); $recaptcha = json_decode($recaptcha); if($recaptcha->success ==true){ if($recaptcha->score >= 0.5){ echo "Recaptcha Success"; }else{ echo"<pre>"; print_r("Recaptcha Not Verified"); echo"</pre>"; } }else{ echo"<pre>"; print_r($recaptcha); echo"</pre>"; } } But receiving the below error stdClass Object ( [success] => [error-codes] => Array ( [0] => invalid-input-secret ) )
- 2 replies
-
- php
- recaptcha php error
-
(and 3 more)
Tagged with: