![]() |
Recaptcha 2.0 validation problem I am having a problem with recaptcha 2.0 validation. I already added captcha into my form, now I need to make it validate captcha before sending message via form. Here is a whole validation code: Code: $(document).ready(function(){ |
Re: Recaptcha 2.0 validation problem Hey mate, You can't validate the captcha from JS, as you don't have the secret key at that point.. It's not really useful to do anyway IMO :) You'll need some code like this on your forms action page: $secret = 'your recaptcha secret'; $captcha_url = "https://www.google.com/recaptcha/api/siteverify?secret=${secret}&response=".$_POST['g-recaptcha-response'].'&remoteip='.$_SERVER['REMOTE_ADDR']; if ($data = file_get_contents($captcha_url)) { $obj = json_decode($data); if (! $obj->success) { //redirect back to form with error message, or something... } else { //process form and do whatever you want - the captcha was good } } Cheers, Michael |
Re: Recaptcha 2.0 validation problem Thanks Michael, I'll try your given code. |
| All times are GMT -6. The time now is 01:12 PM. |