Navigation:    Home arrow Form Image Verification
PHP Form image verification PDF  
Digg Reddit Ma.gnolia Stumble Upon Facebook Twitter Google Yahoo! MyWeb Furl" BlinkList Technorati Mixx Bookmark
Article Index
PHP Form image verification
Page 2
Page 3
 

The html file random_sample.html is a sample of how to use the random image.

<?php
session_start();
?>
<HTML>
<HEAD>
<TITLE>Random image sample</TITLE>
<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=iso-8859-1\">
</HEAD>
<BODY>
<?php
$errors=0;
if(isset($_POST['Submit']))
{
$number = $_POST['number'];
if(md5($number) != $_SESSION['image_value'])
echo '<h1>Validation string not valid! Please try again!</h1>';
else
{
echo '<h1>Your string is valid!</h1>';
//do what you want with the data
}
}
?>
<form name="form1" method="post" action="random_sample.php">
<table cellspacing="0" width="600" align="center">
<tr><td valign="top" align="right">Comments</td>
<td><input name="message" size=40 value="...your message here">
</td></tr>
<tr><td colspan=2 align="center">
<font size="1" face="Geneva, Arial, Helvetica, sans-serif"><strong><font size="2">
Please enter the string shown in the image in the form.<br> The possible characters are letters from A to Z in capitalized form and the numbers from 0 to 9.
</font></td></tr>
<tr><td align="center" colspan=2><input name="number" type="text" id=\"number\"></td></tr>
<tr><td colspan=2 align="center"><img src="random_image.php"></td></tr>
<tr><td colspan=2 align="center"><input name="Submit" type="submit"
value="Submit"></td></tr>
</table>
</form>
</BODY>
</HTML>
View demo here If you found this tutorial useful you might be interested to read the following:

 

Installing Apache, PHP, MySQL on a Windows 98/2000/XP Computer
PHP Create Image Thumbnail
Count Words in a string using PHP
PHP Form Image Upload
PHP print random image from a folder