View Full Version : Putting in captcha

12-19-2006, 11:31 PM
I would like to know how to put a catpcha in my existing form... right now i have the form as well as the form output on the index page.... how would i go about making it have a capcha code to where inorder for the form to go through... they would need to enter a captcha code.

12-19-2006, 11:41 PM
Hi, check out hotscripts.com. They have many Captcha scripts with instructions.

12-20-2006, 12:07 AM
yes... but those are if your form and your form handler are seperate.. they are on the same php page.

12-20-2006, 12:23 AM
Your code in a single file has conditional logic to separate the generation and output of the form from the processing of the submitted data, yes.

The code that generates the catpcha must be placed within the conditional code that generates and outputs the form and the code that tests the value from the catpcha needs to be placed within the conditional code with the current form processing logic.

12-20-2006, 01:51 AM
My site is http://urbanfriend.net .... http://nightstarproductions.com/index.phps is the URL to the source ... and http://nightstarproductions.com/captcha.phps is the source for the captcha image... what would i have to put in index.php to verify the captcha... and if someone enters the wrong captcha it wont let them join the train... but instead say: Invalid Verification code, please try again ... instead.

12-21-2006, 12:26 AM


12-21-2006, 01:43 AM
The first two links in your post don't work...

12-21-2006, 02:44 AM
Fixed the second link.. and the new site down... now have it up on http://urbanfriend.net .. that is the site .. the index.phps is the source.

12-22-2006, 01:42 AM


12-22-2006, 04:21 PM
Your code has several forms. For any one of them, do something like the following -

session_start(); // form processing code uses a session, start session at top of page
// the form processing code
// check if the entered value matches the captcha code
if($_POST['capcars'] != $_SESSION['vercode'])
die("Error: The code entered did not match the image.");
// the normal processing code goes here
echo 'You entered the code correctly';
} else {
// the form code
<form method="post">
Enter the characters you see in the image:&nbsp;&nbsp;<input type="text" name="capcars" size="5"> <img src="captcha.php" alt=""><br />
<input type=submit name="subbutton" value="submit">
?>This code works (tested) with your captcha.php file and the $_SESSION['vercode'] variable that it sets.