After entering right image verification code...still im getting an error saying "WRONG IMAGE VERIFICATION CODE"...can anyone tell me why is it happening.
//Let's get all the form fields and set them as variables
$fname = stripslashes($_POST['firstname']);
$lname = stripslashes($_POST['lastname']);
$email = stripslashes($_POST['email']);
$company = stripslashes($_POST['company']);
$message = stripslashes($_POST['message']);
$verify = stripslashes($_POST['verify']);
//Validate mandatory form fields
if (empty($fname) || empty($lname) || empty($email) || empty($message)) {
echo "Fields marked with (*) are required";
$continue_sending = "no";
} else {
$continue_sending = "yes";
}
$admin = "masked.nohappyend@forspammers.com"; //The email you want all the inquiries being sent to
$subject = "MySite Contact Form"; //Set this to whatever you want it to be
$from = "From: ".$fname." ".$lname."<".$email.">";
$content = "First Name: ".$fname."\nLast Name: ".$lname."\nEmail: ".$email."\nCompany: ".$company."\nMessage: ".$message."";
if ($continue_sending == "yes") {
// check to see if verificaton code was correct
if(md5($verify).'decipher_k2s58s4' == $_cookie['contact_verify']){
// if verification code is correct send the message and display success message
$sendnow = mail($admin,$subject,$content,$from);
if ($sendnow) {
echo "<font color=\"green\">Thank You! We will respond shortly</font>";
} else {
echo "<font color=\"red\">Message was not sent. Please try again.</font>";
}
} else { //image verification failed
echo "<font color=\"red\">Image Verification Incorrect</font>";
$save_form_values = "true";
}
}
}
?>
<form action="<?php $_SERVER['PHP_SELF']; ?>?status=send" method="post">
<table border="0">
<tr>
<td valign="top">First Name*:</td>
<td><input type="text" name="firstname" style="width:200px;" value="<?php if ($save_form_values == "true") { echo $fname; } ?>" /></td>
</tr>
<tr>
<td valign="top">Last Name*:</td>
<td><input type="text" name="lastname" style="width:200px;" value="<?php if ($save_form_values == "true") { echo $lname; } ?>" /></td>
</tr>
<tr>
<td valign="top">Email*:</td>
<td><input type="text" name="email" style="width:200px;" value="<?php if ($save_form_values == "true") { echo $email; } ?>" /></td>
</tr>
<tr>
<td valign="top">Company:</td>
<td><input type="text" name="company" style="width:200px;" value="<?php if ($save_form_values == "true") { echo $company; } ?>" /></td>
</tr>
<tr>
<td valign="top">Message*:</td>
<td><textarea name="message" style="width:200px; height:120px;"><?php if ($save_form_values == "true") { echo $message; } ?></textarea></td>
</tr>
<tr>
<td valign="top">Image Verification:</td>
<td><input type="text" name="verify" style="width:200px;" /><img src="verification.php?<?php echo rand(0,9999);?>" alt="Help us avoid spam! Please type the image text in the box" width="50" height="24" align="absbottom" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Send Message" /></td>
</tr>
</table>
</form>
verification.php
<?php
//Declare in the header what kind of file this is
header('Content-type: image/jpeg');
//A nice small image that's to the point
$width = 50;
$height = 24;
//Here we create the image with the sizes declared above and save it to a variable my_image
$my_image = imagecreatetruecolor($width, $height);
//Let's give our image a background color. White sound ok to everyone?
imagefill($my_image, 0, 0, 0xFFFFFF);
//Now we're going to add some noise to the image by placing pixels randomly all over the image
for ($c = 0; $c < 40; $c++){
$x = rand(0,$width-1);
$y = rand(0,$height-1);
imagesetpixel($my_image, $x, $y, 0x000000);
}
$x = rand(1,10);
$y = rand(1,10);
$rand_string = rand(1000,9999);
imagestring($my_image, 5, $x, $y, $rand_string, 0x000000);
/*
We're going to store a ****** in the user's browser so we can call to it
later and confirm they entered the correct verification. The
"decipher_k2s58s4" can be anything you want. It's just our personal
code to be added to the end of the captcha value stored in the ******
as an encrypted string
*/
setcookie('contact_verify',(md5($rand_string).'decipher_k2s58s4'));
imagejpeg($my_image);
imagedestroy($my_image);
?>