Add ReCaptcha to HTML/PHP contact form?

You have to put that function in the file


This code is already here https://github.com/bozdoz/wp-plugin-recaptcha-jetpack/blob/master/recaptcha-jetpack.php#L143-L190

You don't have to add it. You know I'm not a WP fan. The IP part is missing, maybe that's causing the issue?

Change
PHP:
$querystring = sprintf('secret=%s&response=%s', $secret_key, $recaptcha_reponse);

with
PHP:
$querystring = sprintf('secret=%s&response=%s&remoteip=%s', $secret_key, $recaptcha_reponse, $_SERVER['REMOTE_ADDR']);

Hey bro,

What file? I can't put it in the same file where my captcha code is located, that won't work.

321321.PNG


654.PNG


Regarding the Github plugin, I use that one for my Contact Form. Not sure if it can also be used for he captcha on the registration popup. How all this works and how it all connects is so beyond me.

But I tried it. I put the code above back in functions.php, and I did the edit you said in the plugin's php file. I saved, I deleted cache, I did a hard refresh, and I was still able to register without solving the captcha.

Yeah, this is hard stuff. It's not one of those things where I can try and try and try some more and get lucky. I did try, but fail.
 
Oh no no no no.

First you will need to take care of architecture.

Then you need to remove that arcane editor. You want to install visual studio code.

And finally you will need to read that book about php saying that:

all php code must be within special tags

google php starting and closing tags

That will be your first lesson.

https://www.php.net/manual/en/language.basic-syntax.phptags.php
Wrap that function { } into those <?php ?>
 
Last edited:
Oh no no no no.

First you will need to take care of architecture.

Then you need to remove that arcane editor. You want to install visual studio code.

And finally you will need to read that book about php saying that:

all php code must be within special tags

google php starting and closing tags

That will be your first lesson.

https://www.php.net/manual/en/language.basic-syntax.phptags.php
Wrap that function { } into those <?php ?>

I just did, and it looked like it was cool because the code got all colorful, but it killed my entire site :D

asas.PNG



EDIT: Hold on, I closed the php before the last closing tag for the code, wait hold on...
 
That's what happens when you start stacking garbage. Time to start the website all over again.

Ok I tried doing it all again, but again I can register without solving the captcha.

I don't know. It doesn't seem like I'll be able to figure this one out.
 
Ok I tried doing it all again, but again I can register without solving the captcha.

I don't know. It doesn't seem like I'll be able to figure this one out.
Why did you want logic to work in something that has no logic? Scorpion, you gotta see the logic in coding. This is not math, there is actually logic in this!
 
Why did you want logic to work in something that has no logic? Scorpion, you gotta see the logic in coding. This is not math, there is actually logic in this!

Yeah I see logic, I've been doing stuff for days, weeks, years. You see me do many of them.

Like yesterday I had a problem with something I styled. Every time you'd visit or refresh the page, for a second the CSS wouldn't be applied, and then it would be applied. I looked at it, got the idea that maybe it happens because I styled the form, and not all the elements of the form appear instantly. I wasn't sure, but it was worth a shot, the idea made sense.

So I styled the DIV around the form, and solved the problem. Ok, makes sense.

So but this captcha thing, it's beyond me. I figured out where I need to put the code so that the captcha appears exactly where I want it. I figured out how to align it and everything. But when it comes to the verification so that a user actually needs to solve it in order to be allowed to proceed, I am totally lost on that. That doesn't require logic, it requires knowledge, which I don't have :p
 
So but this captcha thing, it's beyond me. I figured out where I need to put the code so that the captcha appears exactly where I want it. I figured out how to align it and everything. But when it comes to the verification so that a user actually needs to solve it in order to be allowed to proceed, I am totally lost on that. That doesn't require logic, it requires knowledge, which I don't have :p
Ahh, knowledge. I just had to use a bucket of cold water on my head to calm down after looking for the proper word I didn't know is wrong.

There is never too much knowledge.
 
Ahh, knowledge. I just had to use a bucket of cold water on my head to calm down after looking for the proper word I didn't know is wrong.

There is never too much knowledge.

Actually, none of the recaptcha solutions really work how I want them.

The one on the contact form that I added with a plugin, if submit the form without solving the recaptcha, the page does like a soft refresh, you get the recaptcha error on the page there (this is good), but all of the fields you filled above (username, email, message, etc) are now empty. Which means you have to fill them out again. That's not cool.

The one I added on my blog comments, if you submit a comment and don't fill the captcha you get taken to another page where you see the error. That's not cool, the error should appear on the same page, preferably with no refresh, or at least a soft refresh. But at least when you hit to go back, your comment and the stuff you filled out is still there, and this is good.

And of course the registration page, I didn't even manage to add recaptcha there. But even if I did, I wouldn't be entirely happy with how it works.

So yeah, it's hard out here for a pimp... :p
 
https://developers.google.com/recaptcha/docs/v3 All the codes that will be useful for you are in the link. You can do this with just 2-3 lines of code.
 
Back
Top