Reputation: 63
I have an issue with recaptcha, Its not sending the mail, even when if I have enter the code correctly, I have try so many times and I have even got someone else to try it and another person and secondly in my contact.php
Upvotes: 0
Views: 111
Reputation: 5520
The problem might be the way you're checking value of $captchaerrorMsg.
<?php if ($captchaErrorMsg){ ?>
<p style="color:red">Please enter correct verification code.</p>
<?php } ?>
PHP does evaluate what it think you're checking when you don't clearly specify what it is. Therefore does the above code also run when $captchaErrorMsg is 1, when it is true or even when the variable just contains a character, like 'x'.
You only want to run the above code when error message is true, therefore you could do like this:
<?php if ($captchaErrorMsg === true){ ?>
<p style="color:red">Please enter correct verification code.</p>
<?php } ?>
If it still doesn't work, you will have to figure out the actual value you're getting. Just do a var_dump of the variable like this:
var_dump($captchaErrorMsg);
If this doesn't work, look at this workaround at weird reCaptcha error in PHP
Upvotes: 0
Reputation: 23001
Your variable is $response, but you're checking to see if $resp is not valid. Change this:
if (!($resp->is_valid)) {
$captchaErrorMsg = true;
}
To
if (!($response->is_valid)) {
$captchaErrorMsg = true;
}
Upvotes: 1