View Full Version : Captcha how to???

04-07-2007, 05:49 PM
I have a few captcha scripts and have them working great, but how do I make it work in my current contact and registration forms?

I can post my captcha scripts that do work on my machine but can't seem to get them to work on my current pages.

Is there someone who can give me a tip or two.

04-08-2007, 10:29 AM
whats not working ?

more info please

04-08-2007, 10:35 AM
The problem is that I have the captcha working now with my form, but it is blank on the server that I am hosting and I think I need to get a file called captcha.jpg to get it work.

Will post if there are any other, q's.

04-08-2007, 10:37 AM
The problem is that I have the captcha working now with my form, but it is blank on the server

so its working locally but not on the live machine

04-08-2007, 10:43 AM
Yes, but I think I need an image called captcha.jpg on the server, but I don't need it on my machine, which is odd.

04-08-2007, 11:08 AM
Ok Got it work but the problem I have is that the error dsiplays at the top of the page and not next to the textbox, any ideas on how to do that?

04-08-2007, 11:11 AM
Here is the code that I am using:
This verifies the captcha:

if ($_POST["vercode"] != $_SESSION["vercode"] OR $_SESSION["vercode"]=='') {
echo '<strong>Incorrect verification code.</strong><br>';
} else {
// add form data processing code here
// echo '<strong>Verification successful.</strong><br>';
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);


BUt I would like the error to display next to the textbox, any ideas how?

04-08-2007, 11:18 AM
assign the error code to a variable and echo the variable in the page where you want it display'd

04-08-2007, 11:22 AM
Using this:

or die(mysql_error()

My version would be this:

or die(mysql_error(#error_number)

Is this right?

04-08-2007, 11:35 AM
built in error handling is good for debugging but its much nicer to create your own

where you have...

echo '<strong>Incorrect verification code.</strong><br>';

just do this...

$error = '<strong>Incorrect verification code.</strong><br>';

then you can echo the $error var anywhere you like on the page

04-08-2007, 11:44 AM

I guess it takes the observer to solve the most easiest issues.


04-08-2007, 11:52 AM

if you building a robust, scalable application then its best to keep all your error codes together

create a page called errors.php

then add...


define('A123', 'error: this is an error message');
define('A124', 'error: this is another error message');
define('A125', 'error: this is one too');


add an include to the page you want to call the errors


then to call them just set an $error var like this...

$error = A123;

then just echo $error

04-08-2007, 11:57 AM
Will do thank you.

04-08-2007, 12:01 PM
On top of that I need to now add a check to to see if the user actually clicked submit or not;

Will do it with a hidden field, I don't enjoy naming my submit buttons.

Thanks again.