samedi 11 avril 2015

google recaptcha widget not showing up on contact form

I have a registeration form on my site that has the google recaptcha (the one with the numbers) that works perfectly. However when I try to get the wiget to show on my contact form it doesnt appear...I can get the google nocaptacha recaptcha (checkmark box) to appear but the server side wont work for that captcha. So what i want like to do is implement the google recaptcha to actually show and work on the contact form. the server side works but widget doesnt appear:S this is part of the contact form code



<div id="left_contact">


<?php
if (empty($_POST['email'])) // Si on la variable est vide, on peut considérer qu'on est sur la page de formulaire
{
echo
'
<div class="box_contact" style="font-size:14px;">

<form method="post" action="">


'
?>
<?php
require_once('recaptchalib.php');
$publickey = "6LcIAgETAAAAAGAGMylfFD_t4nkFuLXFYWZ7yEXw"; // You got this from the signup page.
echo recaptcha_get_html($publickey);
?>
<?php
'



<table style="margin:10px 15px 15px 15px;">
<tr><td colspan="2" style="padding-left:6px;font-weight:bold;">Fill in this form to send us an email</td></tr>

<tr>
<td style="padding-top:30px;padding-left:6px;">First name</td>
<td style="padding-top:30px;padding-left:6px;">Last name</td>
</tr>

<tr>
<td><input type="text" name="name_1" required placeholder="First name" class="input_box" style="width:280px;margin-right:0px;" /></td>
<td><input type="text" name="name_2" required placeholder="Last name" class="input_box" style="width:280px;" /></td>
</tr>

<tr>
<td style="padding-top:30px;padding-left:6px;">Email</td>
<td style="padding-top:30px;padding-left:6px;">Phone number</td>
</tr>

<tr>
<td><input type="text" name="email" required placeholder="Email" class="input_box" style="width:280px;margin-right:0px;" /></td>
<td><input type="text" name="contact" required placeholder="Phone number" class="input_box" style="width:280px;" /></td>
</tr>

<tr>
<td colspan="2" style="padding-top:30px;padding-left:6px;">Your Message</td>
</tr>

<tr>
<td colspan="2">
<textarea name="message" required placeholder="Message" class="input_box" style="height:160px;width:585px;margin-right:20px;resize:none;" ></textarea>
</td>
</tr>

<tr>
<td colspan="2"><input type="submit" value="SEND" class="btn_fine"/></td>
</tr>


</table>

</form>

</div>


then i have this in my mail send/confirm .php file which to verify the captcha. this works but widget doesnt show up:S



require_once('recaptchalib.php');
$privatekey = "mywebsitesprivatekey";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
// Your code here to handle a successful verification
}

Aucun commentaire:

Enregistrer un commentaire