Connecting Tech Pros Worldwide Help | Site Map

Re CAPTCHA with Tectite Formmail working but small problem

Newbie
 
Join Date: Oct 2009
Posts: 1
#1: 4 Weeks Ago
I've been using Form mailer for a couple years but now have a huge issue with SPAMMERS...

Here is my Formmail code it is located at the top of the PHP file

Expand|Select|Wrap|Line Numbers
  1. <form method="post" action="http://nasf.net/cgi-bin/form1.php" name="NASF Forms ">
  2.     <input type="hidden" name="recipients" value="webmaster@nasf.net" />
  3.     <input type="hidden" name="required" value="realname:Your name,phone:Your Phone Number" />
  4.     <input type="hidden" name="subject" value="2009 NASF CLINIC Enrollment Form" />
  5.       <input type="hidden" name="mail_options" value="PlainTemplate=2009_NASF_Clinic_Enrollment_form.txt" /> 
  6.      <input type="hidden" name="mail_options" value="PlainTemplate=2009_NASF_Clinic_Enrollment_form.txt,TemplateMissing=n/a" /> 
  7.      <input type="hidden" name="good_url" value="http://nasf.net/index.php?id=14" /> 
  8.  
  9.  
  10. Here is my ReCaptcha Code i added above the submit button.. I added the Redirect that i found on a previous post.
  11.  
  12. <?php
  13. require_once('recaptchalib.php');
  14.  
  15. // Get a key from http://recaptcha.net/api/getkey
  16. $publickey = "6Lcy_AgAAAAAAKapihQSjk--oe6lcrb1duOT2rtP";
  17. $privatekey = "6Lcy_AgAAAAAAHn-b3w9C6rhHNSm3ieDJvR0-TU7";
  18.  
  19. # the response from reCAPTCHA
  20. $resp = null;
  21. # the error code from reCAPTCHA, if any
  22. $error = null;
  23.  
  24. # was there a reCAPTCHA response?
  25. if ($_POST["recaptcha_response_field"]) {
  26.         $resp = recaptcha_check_answer ($privatekey,
  27.                                         $_SERVER["REMOTE_ADDR"],
  28.                                         $_POST["recaptcha_challenge_field"],
  29.                                         $_POST["recaptcha_response_field"]);
  30.  
  31.         if ($resp->is_valid) { 
  32.                       echo ("<meta http-equiv=\"refresh\"content=\"1; url=http://nasf.net/index.php?id=14\">"); 
  33.         } else {
  34.                 # set the error code so that we can display it
  35.                 $error = $resp->error;
  36.         }
  37. }
  38. echo recaptcha_get_html($publickey, $error);
  39. ?> 

MY PROBLEM....

I don't know what to do to get the Page Redirected and Email sent to me

IF i remove the
<input type="hidden" name="good_url" value="http://nasf.net/index.php?id=14" />
from the Formmail code i get this response.

Thanks! We've received your information and, if it's appropriate, we'll be in contact with you soon.

Your form submission was processed by (8.16), available from www.tectite.com.


If I put the code back in the formmail part.. It redirects to the thankyou page but no matter which i do.. I don;t get the emails.....

Can you recommend a way to incorperate these together so that the form works.. Spam is reduced or stopped and i get the email forms sent to me.

Thanks
ERIC
Atli's Avatar
Moderator
 
Join Date: Nov 2006
Location: Iceland
Posts: 3,739
#2: 4 Weeks Ago

re: Re CAPTCHA with Tectite Formmail working but small problem


Hey.

The part of that code that checks if the reCAPTCHA validation was successful is meant to go into the page that receives and validates the form when it is submitted.

Like:
Expand|Select|Wrap|Line Numbers
  1. <!-- Page: index.php -->
  2. <form action="validate.php" method="post">
  3.     <!-- Insert your fields here -->
  4.     <?php
  5.         require_once('recaptchalib.php');
  6.         $publickey = "...";
  7.         echo recaptcha_get_html($publickey);
  8.     ?>
  9.     <input type="submit">
  10. </form>
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.     /** Page: validate.php **/
  3.  
  4.     require_once('recaptchalib.php');
  5.     $privatekey = "...";
  6.     $resp = recaptcha_check_answer($privatekey,
  7.         $_SERVER["REMOTE_ADDR"],
  8.         $_POST["recaptcha_challenge_field"],
  9.         $_POST["recaptcha_response_field"]
  10.     );
  11.     if (!$resp->is_valid) {
  12.       // You might want to do something less anoying here.
  13.       // This will just send the user back to a cleared form.
  14.       header("Refresh: 3; url=index.php");
  15.       echo "Captcha validation failed, please try again.<br>";
  16.       echo "Error message: " . $resp->error;
  17.     }
  18.     else {
  19.         // Send your email, or whatever you do, here.
  20.     }
  21. ?>
You can't just copy/paste the example code directly into your form. You have to integrate it into your pages.
Reply