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!
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
@@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.
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?
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?
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.
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: /
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?
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.
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
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
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.
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 :)
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. :)
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 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 ...
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~
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
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?
You are the only guy who explains this properly. THANK YOU SO MUCH
My pleasure, thank you! :)
This is the best tutorial on this topic. Precise and crystal clear information delivered with good and clear English diction. Thank you Senaid.
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.
I saw almost all your videos on php, you deserves a great salute. thank you brother
Appreciate that, thank you!
Simples, prático e objetivo. Único tutorial que realmente valeu a pena assistir, parabéns!!!!
Thank you :D
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.
I was struggling to implement reCAPTCHA V2 and you provided a simple and well explained solution, thank you very much!
i honestly don't have a choice other than to like this video, it's great
thank you
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 :)
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! Finally a simple implementation that works without adding any complexity!
Kenneth Wood 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.
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. :)
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?
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?
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 :)
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: /
Thanks man! it helps a lot
Glad I could help :)
A very simple and easy to understand explanation. Thanks!
Thank you !!
A good lesson. Everything is clear and simple. Thank.
thank you :)
I've been really struggling to implement this. So will start again following your code.
Thank you so much sir
you are the HERO sir
Happy to help
@@SenaidBacinovic thank you sir
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!
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?
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?
thanks bra , at last clean and simple lesson. Works like a charm
thank you :)
thanks brother
You' re welcome !
Sir many many thanks :) Helped me this video...
Sir is Nice Video to integrated reCAPTCHA to PHP localhost
Thanks bro! Nice tutorial, very simple and easy to understand. You're amazing
Thank you :)
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.
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! :)
Grato. Me ajudou bastante.
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! :)
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
You helped me a lot. Thanks!
Daniel Marques it's my pleasure, thank you for the feedback :)
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
You have solution to all my problems... subscribed :)
Glad I could help, thank you! :)
great tutorial just made it on my website, thanks :)
Awesome, I am so happy that I could help you.
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.
You helped me lot , Thank you very much for this tutorial
Awesome, glad I could help. :)
Thank you very much for this tutorial.
It's my pleasure, thank you! :)
Thank you, you helped me a lot with your video. :)
Glad to hear that! You're welcome.
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?
So impress by this video
Glad to hear you. It's my pleasure.
thank you
Really appreciate for making this video....
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.
helped a lot. Thanks man
Glad I could help :)
Thank you, you made this look so easy it's incredible
thank you :)
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.
Solid tutorial! Thanks for the video!
Thank you :)
Thank you sir i have learn more things buz of you ,plz u can upload video for like and comment process how to work with jquery
Thank you so much! Can you please give me a little bit more information on what you are trying to achieve?
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 :)
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. :)
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.
How do I get ReCaptcha to send the content of the form to my email? Please advise!
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 ...
wow thanks!
Easy method, easy way you make, love you 😍
Great tutorial! Thanks!
thank you :)
Thanks for this.
thank you :)
Thank you! Nice and easy :)
Sharon Gutierrez Thank you so much. Appreciate the support. :)
Helped me alot ^^ thank you
Glad to hear that! You are welcome.
Thank you so much it really helps a lot sir! More tutorial to come :)
You have very good skills! Pleasure to watch
Rock Star!
Fahad Noor thank you :)
Excellent
wonderful :-) thanks bro..very successfully
thank you :)
Coding Passive Income u save me😊
Awesome , thanks sir
Thank you!
thank you for this helpful tutorial
OUALID KHALDI It is my pleasure! Thank you for support! :)
I am getting an error “missing-input-response” why is that?
How do you implement this to bring up the picture challenge? Isn't that v2?
(All figured out)
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~
life saver
Hey, how do you make the reCaptcha field a "required" field?
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
Good stuff. Thank you!
great job.. thanks
thank you :)
You are the best :*
Thank you!
yes
thank you bro
thank you :)
Make a video how to bypass recaptcha ♥
Awesome. You are great !
tejas gokani Thank you so much. Appreciate the support! :)
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. Liked and subscribed!
thank you :)
thank you soo much :)
My pleasure, thank you!
great video...thanks a lot...
thank you :)
Thanks
Thank you :)
Very good tutorial, thank you
thank you :)
thank you great help
Thank you for support :)
Yes!
Amazing! :D
Please create logout when user click wimdow back btn or click window refresh. For security..
Very good this lean thank and than my friend 🌹
My pleasure, thank you :)
Learn *** thank *** 😅
Very good tutorial. Any chance on doing a tutorial for Recaptcha v3?
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!
Hvala!
thank u
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?