473,395 Members | 1,539 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Re CAPTCHA with Tectite Formmail working but small problem

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
Oct 22 '09 #1
1 3885
Atli
5,058 Expert 4TB
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.
Oct 22 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: mcp6453 | last post by:
I am trying to use Jack's FormMail script (http://www.dtheatre.com/scripts/formmail). Since I'm brand new at PHP and not very good at HTML, I have an easy question, which I will narrow down. When...
0
by: Aidan | last post by:
Hi PHP guru's, I've been working on creating a PHP formmail script. I have a working version, but I'd like to get feed back on what security holes I may have opened, and what I could do better....
5
by: Barry Morris | last post by:
Hello One web site I have written has a 'register your interest' form which simply e-mails the data, this is working fine except some people seem to get off on repeatedly using the form to send...
4
by: laredotornado | last post by:
Hi, I'm using PHP 4.4.4 and have downloaded the free script formmail.php (version 4.1b). Wondered if anyone had experienced the same problem I'm having. I'm submitting a form to formmail.php, but...
7
by: ronaldh | last post by:
can anyone help me to set up a formmail.cig i am in over my head last to days trying and no luck i have managed to completly delette my cgi doc all together and need to start from scratch please help...
7
by: kyle.reddoch | last post by:
I am having trouble setting up my formmail to work with the captcha.php script i have. Any help would be greatly appreciated. Thanks!
4
by: Jeigh | last post by:
My host has been 'upgrading' lately and its caused me a whole mess of problems. The last of which being that my CAPTCHA form no longer works. I remember to get the CAPTCHA working it took me weeks to...
15
by: sb5309 | last post by:
When one uses CAPTCHA (form with verification code), a session is required to keep the session data. In examples that I have seen on the net, I did not see a session is closed after use. ...
10
by: jeddiki | last post by:
Hi, I have a captcha script which should pick up a background image and add some random letters to it and re-display This is the part of the form that the captcha image is part of: <span...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.