well the two numbers which the user will see is again through images right ?
Main Topics
Browse All TopicsHi experts,
I have a registeration form
I need to add image number validation that is i generate a randum number from the server and create and iamge with that number and show the iamge to the user and then he enters that number in the text box and submit that number to the server where the check is performed
Links to sample code will be gr8
Thanks
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
//newform.php
<?php
session_start();
$_SESSION["captcha"]=verif
function verificationNumber($chars=
$pass="";
$harfler=array("a","b","c"
for ($i=1;$i<=$chars;$i++){
$pass.= $harfler[rand(0,count($har
}
return $pass;
}
echo '<img src="catchpa.php" border="0" />';
?>
//catchpa.php
<?php
/*
You can use backgrounds for it
and you can use imagettftext instead of imagestring to give some angles foreach letter
*/
header("Content-type: image/png");
$im = @imagecreate(100, 50) or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
$vernum=$_SESSION["captcha
imagestring($im, 4, 5, 5, $vernum , $text_color);
imagepng($im);
imagedestroy($im);
?>
<?php
session_start();
$_SESSION["captcha"]=verif
function verificationNumber($chars=
$pass="";
$harfler=array("a","b","c"
for ($i=1;$i<=$chars;$i++){
$pass.= $harfler[rand(0,count($har
}
return $pass;
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9" />
<title>Untitled Document</title>
</head>
<body>
<?php
include_once "catchpa.php";
?>
</body>
</html>
You need to define and upload every chars image as gif in this example.
<?php
$vernum=$_SESSION["captcha
for($i=0;$i<strlen($vernum
echo '<img src="'.$vernum{$i}.'.gif" >';
}
?>
Sorry - was offline for some time.
The two numbers would be actually text; no images are needed. If someone would want to submit the form using a software robot, they still would need to write quite a bit of code to extract the figures. It can be done without major effort, but I guess there are easier targets available...
Anyway, it works for me and its an easy and fast solution to the problem.
Here's the code I'm using:
// somewhere at the top or in a function library file.
// Creates a piece of HTML which looks like a number to the user, but contains lots of other digits,
// e.g. <span class="539244">9</span><sp
// => 992
// could be improved by using hex codes instead of numbers, etc.
function numberstring($n)
{
$res = '';
while ($n > 0)
{
$rem = $n % 10;
$n = ($n - $rem) / 10;
$res = '<span class="'.rand(0,999999).'"
}
return $res;
}
// Form:
<tr>
<td valign="top">Spam protection</td>
<td valign="top">Recently, we've received a lot of spam. Please prove that you're human by entering the result of the calculation into the following field:
<?php
$arg1 = rand(100, 999);
$arg2 = rand(1, 9);
if (rand(0, 10) < 5)
{
$res = $arg1 - $arg2;
$task = numberstring($arg1).' - '.numberstring($arg2);
}
else
{
$res = $arg1 + $arg2;
$task = numberstring($arg1).' + '.numberstring($arg2);
}
// save correct result
$_SESSION['res'] = $res;
?>
<p><?php echo $task; ?> = <input name="calcres" type="text" /></p>
</td>
</tr>
// Evaluation of result:
$calcres = safeREQUEST('calcres', '');
// safeREQUEST is a utility function, essentially a wrapped $_REQUEST['...']
$savedOK = TRUE;
// ... other validations
if ($calcres == '')
{
$savedOK = FALSE;
$errmsg = 'Please enter the result of the calculation below so we know that you're human.';
}
if ($_SESSION['res'] != $calcres)
{
$savedOK = FALSE;
$errmsg = 'Sorry - we think that you've entered the wrong result for the calculation below. Please try again.';
}
// ... continue processing only if $savedOK == TRUE
HTH, J
Hi I am new to this. I try to use your code and all sorts of error messages I got. Some to do with 'you've' appostrophy. In any case I dook out the appostrophy and still not working. Is there anyway you could sample with a small complete form please so that I can see how it works.
Thanks for your contribution.
Business Accounts
Answer for Membership
by: fulscherPosted on 2006-09-22 at 03:18:51ID: 17576438
Since so many people use authentication with images, there are some clever algorithms around to actually OCR these images. If you use a completely different scheme, chances are that nobody will bother to crack it.
I've been using a simple scheme: I ask the user to add two numbers and enter the result in a field. If the result is correct, processing continues. If it isn't, it's most probably a robot. If the user can't add two numbers (it's a three digit number plus or minus a one-digit number), he's not supposed to use this site anyway. There are many variants to this scheme, for example, showing the numbers as text instead of figures ("four" instead of "4").
Just a thought...
J.