I added a reCAPTCHA v2 to my event registration website but I didn't tie it with Google, thinking that disabling the submit button until the reCAPTCHA was checked would be enough. I was wrong. Once my website went public, I got a flood of people registering for the event. Things were smooth for the first two days, however, on the third day some idiot had a robot register fake participants to my event. It was so bad. I was getting around one new registration every three to five seconds. I found your video and quickly implemented the fix by connecting the reCAPCHA with Google. Suddenly I stopped getting fake registrations. I did a quick registration test to make sure that registration was still working, and thankfully it was. Your video saved my event! Thank you!
My v2 reCAPTCHA v2 works on my test server, localhost, and partially on my live domain. On the live domain, I get the green tick after selecting the correct images in the Captcha, however, when I press the Save button I receive the message 'Verfication Failed'. I have added both domains to the list of domains in the v2 settings. Any ideas?
I have a very troubled problem reCAPTCHA security validation I have to go out to confirm when I go to a site but I do not go out to confirm it on any site and I can not sign up or I can not enter the sites I get confirmation on the laptop but not on the PC please try every way I uploaded my dlls and tried different browsers. I tried the combofix. I did not try adw. I do not want to format the mmm: /
The one MAIN thing Sir your NOT checking for is what if someone leaves a field empty but they still check the ReCaptcha? What error are they going to get or will the ReCaptcha still work?
Hello Senaid, I have a question... do I need to do something different if i am submitting my form with ajax? because at the moment i am doing my implementation exactly as shown in this video. and I get the error that says something along the lines "missing-response-input" so i am guessing this has to do with the fact that all the other values from the form get passed through ajax except for the captcha field. I don't think this field exists in the send() method if not specified by me right? so this might work with posting a form traditionally using names but otherwise no... or am i wrong?
Nice and simple to understand, However, I wish to ask you if thesame procedure can be followed fof a live serve domain name or what do I need to change
@@SenaidBacinovic hey thanks for responding; I actually 'put it off' until a few moments ago. I figured some of the code you had I didn't need; and it didn't work at first; I ended up removing the extra code and 'mistakenly' discovered that just putting the api.js in the Head area 'seems' to be enough ......... going to update a few more codes and see if the theory is right; maybe googles 'simple documentation' is enough afterall; thanks for this tutorial however!!
@@topnetworkersgroup Hmm, that is interesting. After all, it all depends on your entire project structure, and maybe you need to make a few changes in order to be able to use it.
sir I keep getting invalid input response. could it be because I use ajax with my form? do I need to pass recaptcha code with ajax from my form? how do I do that? thank you
It doesn't matter, but you need to know how to use single/double quotes properly. Example: Let's imagine we have one variable: $number = 1; * echo 'number = $number'; ----> OUTPUT: number = $number * echo "number = $number"; -----> OUTPUT: number = 1 * echo 'number = ' . $number; -----> OUTPUT: number = 1 So, in conclusion it means that if you're using variable inside single quotes, it will actually only display the variable and not the data inside the variable, which with double quotes it will work as expected. Hope this helps.
Great tutorial, but do you need to have the $username text field (or any other fields) to get it to work? I have a form and the fields have their own verification. I just need the catpcha to verify.
Not really. You don't need any of those, I just made them for the purpose of this tutorial. You only need the part that I have copied from the Google website.
I have it on a form using bootstrap, that has its own validation, and it's not working correctly. I tried the code without Bootstrap, and it worked perfectly, so still tinkering to figure it out.
I'm making some progress, but I could use another pair of eyes. I have it validating (preventing submission until the user checks the "I'm not a robot" checkbox.) But I'm having trouble getting the validation error message to show for the captcha specifically. Page is here: beta.prospectors.com/contact.php. Contact.php html is:
Thank you for this, very helpful. Now, in the case of successful verification, I need to pass the forms info to a page that stores those info in a database. What is the command to do that? Because before implementing captcha I was using the form action command but now I don't know how to do it ...
Hello! I had troubles using your example and many others' examples. Finally, I found out why. And my solution could help a lot of people having the same problem as me. Your example uses file_get_contents. On many shared hosts, your example won't work because of that. So I tried with cURL instead and finally got it to work. Can I post here the curl example? Very easy to implement and could help other people. You could also offer that as an alternative code for those having problems with file_get_contents.
+Alexandru Stefan It may be an idea to also include the USER-AGENT for completeness (being as some CORS issues can be remedied by its inclusion) - so, for instance, one would add the following to your code: curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
Hi, when I use your code, message about failing verification displays even BEFORE validation, what should I add to get message AFTER clicking on submit button? Thanks in advance man :)
hey senoid everything works well but at the bottom of input it says localhost is not in the list of supported domains for this site key what does it mean?
Very nice tutorials, I learned a lot from them. I just have one question. If I don't submit the 'I'm not a robot' button but save directly, the form will get a warning that I forgot to submit that I'm not a robot button. But my form now is also reset. All fields are empty again. If I make a long form and some one made a mistake, the whole form will be reset and have to be typed in again :( So how does it work that by mistake the form input will not be deleted?
Thank you! For your problem, you can use two different approaches: - use javascript and prevent form submitting before someone click on that button - directly from PHP output the data to input "value" attribute from $_POST Hope this helps. :)
Sir, is there anyway to use CDN to cache message from php server so that client side won't have to frequently request the info within DB for saving the performance of server load~
Thank you much, it's ridiculous Google doesn't have something like this in their documentation. Makes it basically impossible to figure something like this out unless you're a PHP dev.
well finnaly somebody who explain's it instead of just saying *copy the code from the link below* btw tip for you guy's who are starting to learn php or have few knowlege about it $username = htmlspecialchars(strip_tags($_POST['username']); if you actuely want it to be secure
meu filho vc fez o impossivel, pq foi o unico video que assistir que realmente funcionou, parabens pelo trabalho ai, esta melhor que muita documentação por ai! Obrigado e excelente trabalho.
Thank you! It was simple and practical for me. I'm just pointing out this error in minute 3:19 There you say that the Google code must be placed before the closing of the BODY tag; but Google recommends doing it before closing the HEAD tag. Except for that minimal detail, I found the explanation excellent and easy (I highlight the facility, something unfortunately missing in Google) and I put it into practice.
Yes, I said that and still it's something that I recommend. Always you want to make sure that your page load as fast as possible, and you will achieve that by loading HTML and CSS first, and later load all other libraries, images etc.
I have two different tutorials for validation, please take a look: - ruclips.net/video/3oD8ZNb7lLM/видео.html - ruclips.net/video/tGTGYSljQG4/видео.html
Hey Senaid, How do I stop the form being submitted? The code that you showed in the video only echos out true or false after the form was submitted, so how can I stop the form from being submitted and saved if the user does not click the recaptcha??? Thanks again, Donal
got the problem of Trying to get property of non-object in C:\wamp64\www\DB_final-master\login\try.php on line 47 which 45: $response = file_get_contents($url); 46: $response = json_decode($response); 47: if ($response->success) please help me
The form has to be sent because there is a server verification. It serves to protect your server from database attack for example which will accept only request with valid response from recatpcha
It all depends on the Google algorithm. An algorithm will decide will you need to choose from the pictures or it is enough to just click on that checkbox. It's nothing that you can manage from the code.
This is the best tutorial on this topic. Precise and crystal clear information delivered with good and clear English diction. Thank you Senaid.
You are the only guy who explains this properly. THANK YOU SO MUCH
My pleasure, thank you! :)
I saw almost all your videos on php, you deserves a great salute. thank you brother
Appreciate that, thank you!
i honestly don't have a choice other than to like this video, it's great
thank you
I was struggling to implement reCAPTCHA V2 and you provided a simple and well explained solution, thank you very much!
How do you implement this to bring up the picture challenge? Isn't that v2?
(All figured out)
Simples, prático e objetivo. Único tutorial que realmente valeu a pena assistir, parabéns!!!!
Thank you :D
I added a reCAPTCHA v2 to my event registration website but I didn't tie it with Google, thinking that disabling the submit button until the reCAPTCHA was checked would be enough. I was wrong. Once my website went public, I got a flood of people registering for the event. Things were smooth for the first two days, however, on the third day some idiot had a robot register fake participants to my event. It was so bad. I was getting around one new registration every three to five seconds. I found your video and quickly implemented the fix by connecting the reCAPCHA with Google. Suddenly I stopped getting fake registrations. I did a quick registration test to make sure that registration was still working, and thankfully it was. Your video saved my event! Thank you!
I am sorry that you had such a bad experience, but glad that my video could help.
according to the reCaptcha docs you have to use a post request to verify a user
Yes, they said that in docs, but it will work with both. :)
Hi, can I use curl to get some data from a website with this google reCaptcha?
Not sure what do you mean, can you elaborate on that?
My v2 reCAPTCHA v2 works on my test server, localhost, and partially on my live domain. On the live domain, I get the green tick after selecting the correct images in the Captcha, however, when I press the Save button I receive the message 'Verfication Failed'. I have added both domains to the list of domains in the v2 settings. Any ideas?
I have a very troubled problem reCAPTCHA security validation I have to go out to confirm when I go to a site but I do not go out to confirm it on any site and I can not sign up or I can not enter the sites I get confirmation on the laptop but not on the PC please try every way I uploaded my dlls and tried different browsers. I tried the combofix. I did not try adw. I do not want to format the mmm: /
Due to the high quality content on your channel i have decided to subscribe :)
LoL! Thank you for that comment and for subscribing too! You're amazing. :)
im shocked to see 4k res for a tech vid ...most generous coder out there ..big thumps up from my otherwise tiring eyes
@@YOYOSHIVA Somehow I have missed your comment... thank you! :)
Hey, how do you make the reCaptcha field a "required" field?
What is the editor you are using?
PHPStorm :)
A very simple and easy to understand explanation. Thanks!
Thank you !!
Thank you so much. You totally rock. I wouldn't have figured it out on my own.
Thank you so much! Appreciate the feedback and support. :)
thanks bra , at last clean and simple lesson. Works like a charm
thank you :)
The one MAIN thing Sir your NOT checking for is what if someone leaves a field empty but they still check the ReCaptcha? What error are they going to get or will the ReCaptcha still work?
Please create logout when user click wimdow back btn or click window refresh. For security..
Thanks! Finally a simple implementation that works without adding any complexity!
Kenneth Wood thank you :)
How do I get ReCaptcha to send the content of the form to my email? Please advise!
Hello Senaid,
I have a question... do I need to do something different if i am submitting my form with ajax? because at the moment i am doing my implementation exactly as shown in this video. and I get the error that says something along the lines "missing-response-input" so i am guessing this has to do with the fact that all the other values from the form get passed through ajax except for the captcha field. I don't think this field exists in the send() method if not specified by me right? so this might work with posting a form traditionally using names but otherwise no... or am i wrong?
wonderful! everything else was failing for me and this is the only one that worked, not only that, but it was all simple!
Glad I could help, thank you for the feedback :)
Nice of you having the source code in the description.
Nice and simple to understand, However, I wish to ask you if thesame procedure can be followed fof a live serve domain name or what do I need to change
Thank you. Yes, you can use the same procedure, and the only difference is that you instead of "localhost" need to put your domain name.
Thanks man! it helps a lot
Glad I could help :)
I'm getting the "verification failed" msg even when I check the recaptcha? Why is it not working! Pls
Same, just can't get this to work. So frustrating.
A good lesson. Everything is clear and simple. Thank.
thank you :)
Thank you for this Senaid! I wish google provided better documentation for setting up reCAPTCHA. You are a life saver!
My pleasure, glad you like it!
i agree; just got here and hope this video helps me out; the documentation by google is TRASH .....
@@topnetworkersgroup did you find it useful?
@@SenaidBacinovic hey thanks for responding; I actually 'put it off' until a few moments ago. I figured some of the code you had I didn't need; and it didn't work at first; I ended up removing the extra code and 'mistakenly' discovered that just putting the api.js in the Head area 'seems' to be enough ......... going to update a few more codes and see if the theory is right; maybe googles 'simple documentation' is enough afterall; thanks for this tutorial however!!
@@topnetworkersgroup Hmm, that is interesting. After all, it all depends on your entire project structure, and maybe you need to make a few changes in order to be able to use it.
Will you do this for recaptcha v3?
Yes, for sure. :)
Coding Passive Income Thanks, there are no good tutorials for recaptcha v3 so I had to use v2 for my website
I watched this a couple of times and was able to implement it. Thanks.
Amazing, glad I could help you.
Thanks man, this is great! worked first try, great explanation. Subbed :)
Awesome, glad I could help, thank you!
sir I keep getting invalid input response. could it be because I use ajax with my form? do I need to pass recaptcha code with ajax from my form? how do I do that? thank you
Must the secret key be in single or double quotes? I got it to work by putting a double quote for the $url but why is it in double quote?
It doesn't matter, but you need to know how to use single/double quotes properly.
Example: Let's imagine we have one variable: $number = 1;
* echo 'number = $number'; ----> OUTPUT: number = $number
* echo "number = $number"; -----> OUTPUT: number = 1
* echo 'number = ' . $number; -----> OUTPUT: number = 1
So, in conclusion it means that if you're using variable inside single quotes, it will actually only display the variable and not the data inside the variable, which with double quotes it will work as expected. Hope this helps.
Great tutorial, but do you need to have the $username text field (or any other fields) to get it to work? I have a form and the fields have their own verification. I just need the catpcha to verify.
Not really. You don't need any of those, I just made them for the purpose of this tutorial. You only need the part that I have copied from the Google website.
I have it on a form using bootstrap, that has its own validation, and it's not working correctly. I tried the code without Bootstrap, and it worked perfectly, so still tinkering to figure it out.
T AC That's weird. If you want post a code here and I will try to help you.
I'm making some progress, but I could use another pair of eyes. I have it validating (preventing submission until the user checks the "I'm not a robot" checkbox.) But I'm having trouble getting the validation error message to show for the captcha specifically. Page is here: beta.prospectors.com/contact.php.
Contact.php html is:
send.php is:
Thank you for this, very helpful. Now, in the case of successful verification, I need to pass the forms info to a page that stores those info in a database. What is the command to do that? Because before implementing captcha I was using the form action command but now I don't know how to do it ...
Hello! I had troubles using your example and many others' examples. Finally, I found out why. And my solution could help a lot of people having the same problem as me. Your example uses file_get_contents. On many shared hosts, your example won't work because of that. So I tried with cURL instead and finally got it to work. Can I post here the curl example? Very easy to implement and could help other people. You could also offer that as an alternative code for those having problems with file_get_contents.
Thank you for sharing it with us, didn't know that. Absolutely, feel free to post code and help others that have a similar problem. :)
$post_data = "secret=YOURSECRETKEYHERE&response=".$_POST['g-recaptcha-response']."&remoteip=".$_SERVER['REMOTE_ADDR'] ;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "www.google.com/recaptcha/api/siteverify");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER,
array('Content-Type: application/x-www-form-urlencoded; charset=utf-8',
'Content-Length: ' . strlen($post_data)));
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$googresp = curl_exec($ch);
$decgoogresp = json_decode($googresp);
curl_close($ch);
if ($decgoogresp->success == true) {
//Your success message or action here
}
else {
//Your fail message or action here
}
+Alexandru Stefan It may be an idea to also include the USER-AGENT for completeness (being as some CORS issues can be remedied by its inclusion) - so, for instance, one would add the following to your code:
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; rv:19.0) Gecko/20100101 Firefox/19.0");
I had the same problem. Thank you :)
Hi, when I use your code, message about failing verification displays even BEFORE validation, what should I add to get message AFTER clicking on submit button? Thanks in advance man :)
hey senoid everything works well but at the bottom of input it says localhost is not in the list of supported domains for this site key what does it mean?
sheera sai on 2:56 in the video, in the domains section you should insert localhost, just like I did, and everything should work without any problem.
Coding Passive Income thank you so much will try..
sheera sai let me know if there is anything else that I can help you with :)
Coding Passive Income sure you are very humble never seen a brilliant programmer like you
sheera sai thank you so much for support and nice words!
Very nice tutorials, I learned a lot from them.
I just have one question. If I don't submit the 'I'm not a robot' button but save directly, the form will get a warning that I forgot to submit that I'm not a robot button. But my form now is also reset. All fields are empty again. If I make a long form and some one made a mistake, the whole form will be reset and have to be typed in again :(
So how does it work that by mistake the form input will not be deleted?
Thank you!
For your problem, you can use two different approaches:
- use javascript and prevent form submitting before someone click on that button
- directly from PHP output the data to input "value" attribute from $_POST
Hope this helps. :)
I am getting an error “missing-input-response” why is that?
I've been really struggling to implement this. So will start again following your code.
Sir, is there anyway to use CDN to cache message from php server so that client side won't have to frequently request the info within DB for saving the performance of server load~
Sir many many thanks :) Helped me this video...
Thank you much, it's ridiculous Google doesn't have something like this in their documentation. Makes it basically impossible to figure something like this out unless you're a PHP dev.
those1kidds I agree, the documentation is not that good for most of the things.
Coding Passive Income how did you figure it out? Are you just that amazing? (:
Ohh, thank you so much for nice words! :)
You helped me a lot. Thanks!
Daniel Marques it's my pleasure, thank you for the feedback :)
You have very good skills! Pleasure to watch
Very good tutorial. Any chance on doing a tutorial for Recaptcha v3?
just saw your vid the first 2 sec, I already love the accent and everything. instantly liked the video, now lets watch it. :P
it worked?
helped a lot. Thanks man
Glad I could help :)
thank you. very very clear and useful.
how to validate recaptcha in client side, plz help
well finnaly somebody who explain's it instead of just saying *copy the code from the link below*
btw tip for you guy's who are starting to learn php or have few knowlege about it
$username = htmlspecialchars(strip_tags($_POST['username']); if you actuely want it to be secure
Thank you, and great advice.
Solid tutorial! Thanks for the video!
Thank you :)
meu filho vc fez o impossivel, pq foi o unico video que assistir que realmente funcionou, parabens pelo trabalho ai, esta melhor que muita documentação por ai! Obrigado e excelente trabalho.
Thank you, glad I could help :)
Thank you! It was simple and practical for me. I'm just pointing out this error in minute 3:19
There you say that the Google code must be placed before the closing of the BODY tag; but Google recommends doing it before closing the HEAD tag.
Except for that minimal detail, I found the explanation excellent and easy (I highlight the facility, something unfortunately missing in Google) and I put it into practice.
Yes, I said that and still it's something that I recommend. Always you want to make sure that your page load as fast as possible, and you will achieve that by loading HTML and CSS first, and later load all other libraries, images etc.
Grato. Me ajudou bastante.
So impress by this video
Glad to hear you. It's my pleasure.
how to make validation when all from the field is filled then caption are working.......?
I have two different tutorials for validation, please take a look:
- ruclips.net/video/3oD8ZNb7lLM/видео.html
- ruclips.net/video/tGTGYSljQG4/видео.html
but this video not helpful for me.......?
can you find any easy way for me.........?
It can't be easier than that, I am sorry.
Hey Senaid,
How do I stop the form being submitted?
The code that you showed in the video only echos out true or false after the form was submitted, so how can I stop the form from being submitted and saved if the user does not click the recaptcha???
Thanks again,
Donal
brother write if else statement
You have solution to all my problems... subscribed :)
Glad I could help, thank you! :)
hi mr first of all big up to you! can you teach us on to intergrate the web app with the google email varification
Siwakwi Francis Do you mean on forcing visitors to verify their email before they can keep using some parts of your website?
Easy method, easy way you make, love you 😍
Thanks bro! Nice tutorial, very simple and easy to understand. You're amazing
Thank you :)
ya no funciona asi :(
got the problem of Trying to get property of non-object in C:\wamp64\www\DB_final-master\login\try.php on line 47 which
45: $response = file_get_contents($url);
46: $response = json_decode($response);
47: if ($response->success)
please help me
Have you tried to check what do you have in $response after line 45? Maybe you get nothing from that $url.
Thank you, you helped me a lot with your video. :)
Glad to hear that! You're welcome.
Hmmm... Mine just echos "verification failed" regardless of what input I enter. Any suggestions?
Mine just echos "verification failed" regardless as well. Did you get it figured out?
great tutorial just made it on my website, thanks :)
Awesome, I am so happy that I could help you.
Helped me alot ^^ thank you
Glad to hear that! You are welcome.
Thank you so much sir
you are the HERO sir
Happy to help
@@SenaidBacinovic thank you sir
Could you please post recaptcha v3 in JSP
Great tutorial. Liked and subscribed!
thank you :)
On my mobile phone recaptcha didn't' work. how to change recaptcha.
Sunita Bhatkar Can you please explain what exactly do you mean when you say "didn't work"?
9:22 -> "And now if I try again and hit I'm not a robot"... who are you trying to fool, Senaid? :D
Your videos are awesome! Many thanks!
hehe, thank you! :D
Thank you! Nice and easy :)
Sharon Gutierrez Thank you so much. Appreciate the support. :)
Super, but how to make recaptcha responsive? It looks bad on mobile.
Thank you very much for this tutorial, I followed it step by step but if I do not validate the captcha, the form is also sent, any suggestions?
The form has to be sent because there is a server verification.
It serves to protect your server from database attack for example which will accept only request with valid response from recatpcha
@@TheSebario I got it, thank you.
Really appreciate for making this video....
thank you :)
Great tutorial, thank you!
Stampf Thank you. Appreciate the support. :)
Thank you, you made this look so easy it's incredible
thank you :)
why do i have to pick pictures of cars and you do not??
It all depends on the Google algorithm. An algorithm will decide will you need to choose from the pictures or it is enough to just click on that checkbox. It's nothing that you can manage from the code.
thank you so much for the quick response...
It's my pleasure! Let me know if there is anything else that I can help you with. :)
I tried everything...and could not get it to work...always response failed....
Have you tried to download the source code?
Good stuff. Thank you!
Awesome , thanks sir
Thank you!
ERROR for site owner: Invalid site key
Why it showing recaptcha every time on postback when it has verified the user. I think it should be hidden if user proved to be valid human.
You helped me lot , Thank you very much for this tutorial
Awesome, glad I could help. :)
great job.. thanks
thank you :)
Please make single time use url per user.
i got this error "Notice: Undefined index: g-recaptcha-response in"
How can I solve it?
Can you show me the code?
I did a little bit mistake, but I already solved the problem. Thank you for your reply!
Amazing, glad you made it! :)
Thank you so much it really helps a lot sir! More tutorial to come :)
Thanks for this.
thank you :)
thank you for this helpful tutorial
OUALID KHALDI It is my pleasure! Thank you for support! :)
thanks brother
You' re welcome !
great video...thanks a lot...
thank you :)
Excellent
invalid input secret how to do
Sir is Nice Video to integrated reCAPTCHA to PHP localhost
Awesome. You are great !
tejas gokani Thank you so much. Appreciate the support! :)
Very good this lean thank and than my friend 🌹
My pleasure, thank you :)
Learn *** thank *** 😅