Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

ReCaptcha problem, not verifying.

Here is my index.php

<center>
<form action="verify.php">
<div class="g-recaptcha" data-sitekey="sitekey"></div>
<button value="submit"></button>
</form>

and here is verify.php

<?php
if(isset($_POST['g-recaptcha-response'])) {
   // RECAPTCHA SETTINGS
   $captcha = $_POST['g-recaptcha-response'];
   $ip = $_SERVER['REMOTE_ADDR'];
   $key = '6Ld5T38UAAAAAN9r-7meqh2MGJNC9wq1pFYoOw5N';
   $url = 'https://www.google.com/recaptcha/api/siteverify';

   // RECAPTCH RESPONSE
   $recaptcha_response = file_get_contents($url.'?secret='.$key.'&response='.$captcha.'&remoteip='.$ip);
   $data = json_decode($recaptcha_response);

   if(isset($data->success) &&  $data->success === true) {
       // code goes here
   }
   else {
      die('Your account has been logged as a spammer, you cannot continue!');
   }
}

?>

Doesn't verify.