Can someone please tell me why this doesn't work correctly??? It wont display the 'captcha' numbers! Please help!
email.php
<?php
session_start();
?>
<html>
<body bgcolor="#000000">
<?php
if (isset($_POST["email"])) {
if(!isset($_SESSION["MBF"]))
die("ERROR: You didn't enter the verification code!");
else {
if($_SESSION["MBF"] == $_POST["MrandS"])
{
$ToEmail = 'email@example.com';
$EmailSubject = 'Contact Us';
$mailheader = "From: ".$_POST["email"]."\r\n";
$mailheader .= "Reply-To: ".$_POST["email"]."\r\n";
$mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n";
$MESSAGE_BODY = "Name: ".$_POST["name"]."<br>";
$MESSAGE_BODY .= "Email: ".$_POST["email"]."<br>";
$MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"])."<br>";
mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Could not send email.");
echo '<font color="#00ff00">Your message has been sent.</font>';
}
else
echo '<font color="#00ff00">Sorry your verification code did not match.</font>';
}
}
?>
<center>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<table width="400" border="0" cellspacing="2" cellpadding="0" bgcolor="black">
<tr>
<td width="29%" class="bodytext"><font color="white">Your name:</td>
<td width="71%"><input name="name" type="text" id="name" size="32"></td>
</tr><tr></tr><tr></tr><tr></tr>
<tr>
<td class="bodytext"><font color="white">Email address:</td>
<td><input name="email" type="text" id="email" size="32"></td>
</tr><tr></tr><tr></tr><tr></tr>
<tr>
<td class="bodytext"><font color="white">Comment:</td>
<td><textarea name="comment" cols="25" rows="6" id="comment" class="bodytext"></textarea></td>
</tr><tr></tr><tr></tr><tr></tr>
<tr>
<td class="bodytext"><font color="white">Verify:</td>
<td align="left" valign="top"><font color="white" size="3" face="arial"><b><img src="image.php" width="100" height="30"></b></font><br><input name="MrandS" type="text" id="MrandS" size="22"></td>
</tr><tr></tr><tr></tr><tr></tr>
<tr>
<td><input type="submit" name="Submit" value="Send"></td>
</tr>
</table>
</form>
</center>
</body>
</html>
image.php
<?php
session_start();
// Set the content-type
header('Content-Type: image/png');
// Create the image
$im = imagecreatetruecolor(100, 30);
// Create some colors
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 399, 29, $white);
// The text to draw
$text = rand(1000,9999);
$_SESSION["MBF"]=$text;
// Replace path by your own font path
$font = 'arial.ttf';
// Add some shadow to the text
imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);
// Add the text
imagettftext($im, 20, 0, 10, 20, $black, $font, $text);
// Using imagepng() results in clearer text compared with imagejpeg()
imagepng($im);
imagedestroy($im);
?>