Help implementing Google's recaptcha2

Here’s the code that I’m working with:
[php]<?php
if( !defined(‘Shortilicious’ ) ) {
header(‘HTTP/1.0 404 Not Found’);
exit();
}
ini_set(‘display_errors’, 0);
// grab recaptcha library
require_once “recaptchalib.php”;
?>

<? // your secret key $secret = "6Lc9nxoTAAAAAJalvxefSY2YiNJJjC3f2RKYwDI7"; // empty response $response = null; // check secret key $reCaptcha = new ReCaptcha($secret); // if submitted check response if ($_POST["g-recaptcha-response"]) { $response = $reCaptcha->verifyResponse( $_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"] ); } ?> html, body { font-size: 24px; color: #5858FA; height: 100%; width: 100%; padding: 0; margin: 0; } #full-screen-background-image { z-index: -999; min-height: 100%; min-width: 1024px; width: 100%; height: auto; position: fixed; top: 0; left: 0; } #wrapper { position: relative; width: 800px; min-height: 400px; margin: 100px auto; color: #333; } .form-style-4{ width: 450px; font-size: 16px; background: #495C70; padding: 30px 30px 15px 30px; border: 5px solid #53687E; } .form-style-4 input[type=submit], .form-style-4 input[type=button], .form-style-4 input[type=text], .form-style-4 input[type=email], .form-style-4 textarea, .form-style-4 label { font-family: Georgia, "Times New Roman", Times, serif; font-size: 16px; color: #fff; } .form-style-4 label { display:block; margin-bottom: 10px; } .form-style-4 label > span{ display: inline-block; float: left; width: 150px; } .form-style-4 input[type=text], .form-style-4 input[type=email] { background: transparent; border: none; border-bottom: 1px dashed #83A4C5; width: 275px; outline: none; padding: 0px 0px 0px 0px; font-style: italic; } .form-style-4 textarea{ font-style: italic; padding: 0px 0px 0px 0px; background: transparent; outline: none; border: none; border-bottom: 1px dashed #83A4C5; width: 275px; overflow: hidden; resize:none; height:20px; } .form-style-4 textarea:focus, .form-style-4 input[type=text]:focus, .form-style-4 input[type=email]:focus, .form-style-4 input[type=email] :focus { border-bottom: 1px dashed #D9FFA9; } .form-style-4 input[type=submit], .form-style-4 input[type=button]{ background-color:#ed8223; color:#fff; font-family:'Helvetica Neue',sans-serif; font-size:18px; line-height:30px; border-radius:20px; -webkit-border-radius:20px; -moz-border-radius:20px; border:0; text-shadow:#C17C3A 0 -1px 0; width:120px; height:32px; cursor: pointer; } .form-style-4 input[type=submit]:hover, .form-style-4 input[type=button]:hover{ background: #394D61; }

full screen background image

Create a short URL

<?php print_errors() ?>

Enter web address (URL) here:

<?php foreach ($_POST as $key => $value) { echo '

' . $key.': '.$value.'

'; } ?>

Custom alias (optional):
<?php echo SITE_URL ?>/
May contain letters, numbers, dashes and underscores.

<?php if ($response != null && $response->success) { echo "Hi " . $_POST["name"] . " (" . $_POST["email"] . "), thanks for submitting the form!"; } else { ?> <?php } ?>
[/php]

I’ve followed this tutorial and several others but I can’t seem to get it to work.

I’d like to say sorry for all the posts I’m a noob when it comes to php.

Do you get any errors? What doesn’t work?

No error codes it just I’ve tested it several times without checking the box in the captcha box and it just let’s me submit my info. I need to get this figured out because my url shortening site got hit gard with spam.

Is the posted code, index.php? I don’t see where you are doing anything with the values, so where is the code that takes the submitted data?

This is what the Google Captcha code is getting implemented in:

You are implementing the check in the wrong area. The form sends the get request to, index.php, which doesn’t do anything with the captcha. You want to verify the captcha after figure out you need to process the form.

Update your code, the mysql_ database functions should no longer be used, and mysql_real_escape shouldn’t be used.

Dude you’ve completely lost me I have no idea how to do what your saying.

Okay, let’s see if I can make it simpler.

You have your form in one file. When that file submits, it goes to another page.
Your google check in on the form page, but the form is submitted to another, rendering your check useless. Which is why the validation you are attempting right now, does not work.

Understand?

Got it so how would I go about implementing this to stop the spam from pilling up into my database?

Try implementing what you have in the proper file, then test it.

I have no idea which file to implement it into could you please help I’m stuck between getting info onto my forum to get members and getting this script updated? Plus taking care of a 2yr old who’s always getting his self into trouble.

Sponsor our Newsletter | Privacy Policy | Terms of Service