[Pro] ReCaptcha

Yes, I got it to work, though it was a bit tedious. If you have come as far as the reCaptcha (v2) displaying you only need some simple code.

a) The PHP Feedback Form Action generates php file. If not, you need to set that up in Freeway; under Page / Form Setup. Set the Action attribute to “e-post-go.php” and the Method to POST (that’s what mine is called).

b) Then publish, a file with that name will be generated in the root of your local site folder. Now you deactivate (or delete) the PHP Feedback Form Action to prevent Freeway from overwriting it again.

I then moved the e-post-go.php to a separate folder and linked it to be uploaded automatically with the Upload Extra Resources Action.

c) I then opened the e-post-go.php file, (I use TextWrangler, BBEdit, or TextMate), and added the following lines of code at the top of file, under the initial command <?php

//The following lines of code integrates the Google ReCaptcha. You need to copy and paste your own secret key into the code below. You can edit the response messages to your liking below (under echo)

$email;$comment;$captcha;
    if(isset($_POST['email'])){
      $email=$_POST['email'];
    }if(isset($_POST['comment'])){
      $email=$_POST['comment'];
    }if(isset($_POST['g-recaptcha-response'])){
      $captcha=$_POST['g-recaptcha-response'];
 	 	unset($_POST['g-recaptcha-response']);
    }
    if(!$captcha){
      echo '<h2>You need to mark the reCaptcha box!</h2>';
      exit;
    }
    $secretKey = "PLACE-YOUR-SECRET-KEY-HERE";
    $ip = $_SERVER['REMOTE_ADDR'];
    $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=".$secretKey."&response=".$captcha."&remoteip=".$ip);
    $responseKeys = json_decode($response,true);
    if(intval($responseKeys["success"]) !== 1) {
      echo '<h2>SPAMMER! @$%K Off!</h2>';
    } else {
      echo '<h2>Thanks for your message.</h2>';
    }

//End of Captcha integration

You have to remember to edit this very copy of the file for any modifications, as it will overwrite whatever is on your server automatically whenever you publish and upload.

This should work (as far as I can remember).
Good Luck!


freewaytalk mailing list
email@hidden
Update your subscriptions at: