Problem with image verification code
<p>After entering right image verification code...still im getting an error saying "WRONG IMAGE VERIFICATION CODE"...can anyone tell me why is it happening.
        

<pre><code>        //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."&lt;".$email."&gt;";
        $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 "&lt;font color=\"green\"&gt;Thank You! We will  respond shortly&lt;/font&gt;";    
                } else {
                    echo "&lt;font color=\"red\"&gt;Message was not  sent. Please try again.&lt;/font&gt;";
                }
            } else { //image verification failed
                echo "&lt;font color=\"red\"&gt;Image Verification  Incorrect&lt;/font&gt;";
                $save_form_values = "true";
            }
        }
    }
?&gt;
&lt;form action="&lt;?php $_SERVER['PHP_SELF']; ?&gt;?status=send"  method="post"&gt;
    &lt;table border="0"&gt;
        &lt;tr&gt;
             &lt;td valign="top"&gt;First Name*:&lt;/td&gt;
             &lt;td&gt;&lt;input type="text" name="firstname" style="width:200px;"  value="&lt;?php if ($save_form_values == "true") { echo $fname; } ?&gt;"  /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
             &lt;td valign="top"&gt;Last Name*:&lt;/td&gt;
             &lt;td&gt;&lt;input type="text" name="lastname" style="width:200px;"  value="&lt;?php if ($save_form_values == "true") { echo $lname; } ?&gt;"  /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
             &lt;td valign="top"&gt;Email*:&lt;/td&gt;
             &lt;td&gt;&lt;input type="text" name="email" style="width:200px;"  value="&lt;?php if ($save_form_values == "true") { echo $email; } ?&gt;"  /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
             &lt;td valign="top"&gt;Company:&lt;/td&gt;
             &lt;td&gt;&lt;input type="text" name="company" style="width:200px;"  value="&lt;?php if ($save_form_values == "true") { echo $company; }  ?&gt;" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
             &lt;td valign="top"&gt;Message*:&lt;/td&gt;
             &lt;td&gt;&lt;textarea name="message" style="width:200px;  height:120px;"&gt;&lt;?php if ($save_form_values == "true") { echo  $message; } ?&gt;&lt;/textarea&gt;&lt;/td&gt;
        &lt;/tr&gt;
         &lt;tr&gt;
            &lt;td valign="top"&gt;Image  Verification:&lt;/td&gt;
            &lt;td&gt;&lt;input type="text"  name="verify" style="width:200px;" /&gt;&lt;img  src="verification.php?&lt;?php echo rand(0,9999);?&gt;" alt="Help us  avoid spam! Please type the image text in the box" width="50"  height="24" align="absbottom" /&gt;&lt;/td&gt;
        &lt;/tr&gt;
         &lt;tr&gt;
            &lt;td&gt;&amp;nbsp;&lt;/td&gt;
             &lt;td&gt;&lt;input type="submit" name="submit" value="Send Message"  /&gt;&lt;/td&gt;
        &lt;/tr&gt;
    &lt;/table&gt;
&lt;/form&gt;
</code></pre>

<p><strong>verification.php</strong></p>

<pre><code>&lt;?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 &lt; 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);
?&gt;
</code></pre>
