Hi Raju, I am giving below the code of captcha.php (the one you helped me with in another thread) and the code on the page containing my captcha image. Is that what you want to see?
I started a new thread on this as I felt that the help I needed on this one was for a different reason than the one which I needed while creating the captcha script.
My captcha.php code is as given below:
<?php
//Start the session so we can store what the code actually is.
session_start();
//Now lets use md5 to generate a totally random string
$md5 = md5(microtime() * mktime());
/* We dont need a 32 character long string so we trim it down to 5 */
$string = substr($md5,0,5);
/* Now for the GD stuff, for ease of use lets create the image from a background image. */
$captcha = imagecreatefrompng("captcha.png");
/* Lets set the colours, the colour $line is used to generate lines. Using a blue misty colours. The colour codes are in RGB */
$black = imagecolorallocate($captcha, 0, 0, 0);
$line = imagecolorallocate($captcha,233,239,239);
/* Now to make it a little bit harder for any bots to break,assuming they can break it so far. Lets add some lines in (static lines) to attempt to make the bots life a little harder */
imageline($captcha,0,0,39,29,$line);
imageline($captcha,40,0,64,29,$line);
/* Now for the all important writing of the randomly generated string to the image. */
imagestring($captcha, 5, 20, 10, $string, $black);
/* Encrypt and store the key inside of a session */
$_SESSION['key'] = $string;
/* Output the image */
header("Content-type:image/png");
imagepng($captcha);
# Destroys the image
imagedestroy($captcha);
?>
The code on my page containing the captcha image.
<?php
session_start();
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$vResult = '';
if(strtolower($_SESSION['key']) != strtolower($_POST['security_code'])){
$vResult = 'Security Code is invalid!';
}
else{
die('<a href="discussionforum.php">Discussion Forum</a>');
}
}
?>
<html>
<?php
$page_title = "jppp - My Personal Web Page - Discussion Form";
$page_description = "jppp - My Personal Web Page - discussion form";
include("header.php"); ?>
<body>
<form name="frmCaptcha" id="frmCaptcha" action="" method="post">
<div style="width:300px;border:1px solid #cccccc;font-size:11px;font-family:Verdana;padding:0px 0px 5px 0px;">
<?php echo isset($vResult) ? $vResult . '<br />' : '';?>
<img src="captcha.php?rand=<?php echo rand(1000, 9999);?>" /><br />
Enter text appeared on the image above:<br />
<input autocomplete="off" type="text" name="security_code" id="security_code" value="" />
<input type="submit" name="btnSubmit" id="btnSubmit" value="Submit" />
</div>
</form>
</div>
<div id="leftmenu">
<div id="side1">
<?php include("menu.php"); ?>
</div></div>
<div id="footer"><br /><?php include("footer.php"); ?></div>
</div>
</body>
</html>