0

I have a form that has embedded php
Above html tag I have the following code:

<?php
 if(isset($_POST['sendit'])){
                    $fname = strip_tags($_POST['fname']);
                    $lname = strip_tags($_POST['lname']);
                    $address = strip_tags($_POST['address']);
                    $cityname = strip_tags($_POST['cityname']);
                    $state = strip_tags($_POST['state']);
                    $zipcode = strip_tags($_POST['zipcode']);
                    $phonenum = strip_tags($_POST['phonenum']);
                    $cellnum = strip_tags($_POST['cellnum']);
                    $worknum = strip_tags($_POST['worknum']);
                    $eaddress = strip_tags($_POST['eaddress']);
                    $grad = strip_tags($_POST['grad']);
                    $inhs = strip_tags($_POST['inhs']);
                    $yrgrad = strip_tags($_POST['yrgrad']);
                    $ged = strip_tags($_POST['ged']);
                    $yrofgrad = strip_tags($_POST['yrofgrad']);
                    $referby = strip_tags($_POST['referby']);
}
?>

Before the form tag I have the following code:

 <?php
                    if(isset($_POST['sendit'])){
                    $sendthisto = "your@email.com";
                    $esubject = "New Registration From Autoseum.org";
                    //$atheemailheaders = "CC: your@email.com\r\n";
                    $atheemailheaders = "FROM: noreply@email.org\r\n";
                    $atheemailheaders .= "MIME-Version: 1.0\r\n";
                    $atheemailheaders .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

                    $wantlearn = $_POST['wantlearn'];

                    $theebody = "Hello below is a registrtion form submitted via your Autoseum.org website<br /><br />";
                    $theebody .= "Name: $fname $lname <br /><br /> Address: $address <br /> $cityname $state $zipcode <br /><br /> Phone: $phonenum ";
                    $theebody .= "<br />Cell $cellnum <br />Work: $worknum <br /><br />Email: $eaddress <br /><br />Have You Graduated High School? $grad <br /><br />";
                    $theebody .= "Currently in High School?  $inhs  Year Graduated: $yrgrad <br /><br /> Have a GED? $ged Year of GED: $yrofgrad <br /><br />";
                    $theebody .="Want To Learn: $wantlearn <br /><br />How did you find us? $referby";      


                    mail("$sendthisto","$esubject","$theebody","$atheemailheaders");
                       echo "<center><br /><br />Your Registration Information Has Been Saved To The Database. 
                             A Representative Will Contact You Shortly<br /><br /></center>";
                    }else{
                ?>

The form itself works fine I have no problems with it whatsoever. I am trying to add the recaptcha to this existing form

So between the <form> tag I added this code:

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

Then it says something about for the recaptcha to work the form has submit to a verify.php file which I created and then added the following code:

<?php
  require_once('recaptchalib.php');
  $privatekey = "your_private_key";
  $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
  }
  ?>

I am following this guide:
https://developers.google.com/recaptcha/docs/php

Needless to say its not working and I don't know what I am doing since I have embedded php before recaptcha and not submitting to a php file before I am not sure how to structure this to work. I see a place called (your code here to handle a successful verification so I assume I am supposed to add something there but not sure.

Edited by nufftalon

1
Contributor
1
Reply
26
Views
3 Years
Discussion Span
Last Post by nufftalon
0

I ended up just using

is_int

(PHP 4, PHP 5)
is_int — Find whether the type of a variable is integer

to verify phone numbers and zip codes and added custom php instead for email address.

I ended up not using the recaptcha I guess I iwll see how it goes hopefully client doesnt receive anymore spam.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.