Image Verification

Hey guys,

I am struggling with an image verification… Im almost positive everything is right however when i submit the form it brings up the error code :frowning: If anyone could help me out that would be great!

PHP code:
[php]

<?php if($_POST['go']){ if($_SERVER['REQUEST_METHOD'] == 'POST'){ $error = 0; $msg = ""; $to = '[email protected]'; $subject = $_POST['subject']; $name = $_POST['fullname']; $email = $_POST['email']; $phone = $_POST['phone']; $message = "Message From: $name ($email)\n\n$name is enquiring about $wwyl."; if(!$name){ $error = 1; $msg .= "

Name is required!

"; } if(!$email){ $error = 1; $msg .= "

Email is required!

"; } if(!$subject){ $error = 1; $msg .= "

Subject is required!

"; } if(!$phone){ $error = 1; $msg .= "

Contact Number is required!

"; } if(!$_POST['message']){ $error = 1; $msg .= "

Message is required!

"; } if ($_POST["number"] != $_SESSION["number"] OR $_SESSION["number"]==''){ $error = 1; $msg .= "

Verification does not match!

"; } if($error == 0){ mail($to, "Message from website", $message, "From: $name"); echo "

Message sending successful! We will be in contact soon.

"; }else{ echo $msg; } } } ?>

[/php]

Form:

    <form name="contact_form" method="POST">
    <p>Full Name:</p>
    <p><input type="text" name="fullname" class="inputstyle" /></p>
    <p>Subject:</p>
    <p><input type="text" name="subject" class="inputstyle" /></p>
    <p>Contact Number:</p>
    <p><input type="text" name="phone" class="inputstyle" /></p>
    <p>Email Address:</p>
    <p><input type="text" name="email" class="inputstyle"  /></p>
    <p>Message:</p>
    <p><textarea name="message" class="messageinput"></textarea></p>
    <!--<p>Image Verification:</p>
    <p><img src="image.php" /> : <input name="number" type="text" class="inputstyle"></p>
    <p>(Copy what you see on the image above)</p>-->
    <p><input type="submit" name="go" value="Send" class="submitButton" />
    </form>

image.php
[php]

<?php session_start(); $text = rand(10000,99999); $_SESSION["number"] = $text; $height = 25; $width = 65; $image_p = imagecreate($width, $height); $black = imagecolorallocate($image_p, 0, 0, 0); $white = imagecolorallocate($image_p, 255, 255, 255); $font_size = 14; imagestring($image_p, $font_size, 5, 5, $text, $white); imagejpeg($image_p, null, 80); ?>

[/php]

You need session_start(); at the start of your first PHP code if you wish to retrieve the $_SESSION variable

Sponsor our Newsletter | Privacy Policy | Terms of Service