...

View Full Version : Putting in captcha



TrainReq
12-19-2006, 10: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.

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

TrainReq
12-19-2006, 11:07 PM
yes... but those are if your form and your form handler are seperate.. they are on the same php page.

CFMaBiSmAd
12-19-2006, 11:23 PM
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.

TrainReq
12-20-2006, 12: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.

TrainReq
12-20-2006, 11:26 PM
bump



---

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

TrainReq
12-21-2006, 01: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.

TrainReq
12-22-2006, 12:42 AM
bump



-

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

<?php
session_start(); // form processing code uses a session, start session at top of page
if(isset($_POST['subbutton'])){
// 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.");
}else{
// 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">
</form>
<?php
}
?>This code works (tested) with your captcha.php file and the $_SESSION['vercode'] variable that it sets.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum