I'm having an issue with an image verification I'm trying to adapt from an email form.
Here is the code I have running the contact form with image verification:
http://www.thewebhelp.com/php/php_conta ... alidation/
I find whenever I try to adapt it to verify a form that will submit to a database, I run into trouble.
Here's my code for the form:
- Code: Select all
<h2>Sign The Guestbook</h2>
Please fill out ALL fields before submitting. Thank you.<br /><br />
<form name="form1" method="post" action="?guest=guestbook2" onsubmit='return validate(this)'><input type=hidden name=todo value=post>
First Name: <input name="firstname" class="text" type="text" size="25" maxlength="50" /><br /><br />
Last Name: <input name="lastname" class="text" type="text" size="25" maxlength="50" /><br /><br />
Type Verification Image: <input name="verification" type="text" id="verification" size="5" maxlength="4" /> <img src="inc/verificationimage.php?<?php echo rand(0,9999);?>" alt="verification image, type it in the box" width="50" height="24" align="absbottom" /><br />
Message:<br />
<textarea name="message" cols="5" rows="5" id="message" style="padding:2px; border:1px solid #CCCCCC; width:260px; height:100px; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:11px;"></textarea>
Testimonial? <input type=checkbox name=testimonial value="yes"><br /><br />
<input type="submit" value="Submit" />
</form>
And here's what I have for the submitting:
- Code: Select all
if(isset($todo) and $todo=="post"){
$status = "OK";
$msg="";
if(!isset($firstname) or strlen($firstname) <2){
$msg=$msg."Your first name should be at least 2 characters long. <br />";
$status= "NOTOK";}
if(!isset($lastname) or strlen($lastname) <2){
$msg=$msg."Your first name should be at least 2 characters long. <br />";
$status= "NOTOK";}
if(!isset($message)){
$msg=$msg."Please leave a message. <br />";
$status= "NOTOK";}
if ($testimonial<>"yes"){
$testim="no";
}else{
$testim="yes";}
if(md5($verification).'a4xn' != $_COOKIE['tntcon']){
$msg=$msg."Please make sure your Verification Code is correct. <br />";
$status= "NOTOK";}
if($status<>"OK"){
echo "<font face='Verdana' size='2' color=red>$msg</font><br><input type='button' value='Retry' onClick='history.go(-1)'>";
}else{
$datein = date("Y-m-d");
$query=mysql_query("INSERT INTO table(firstname,lastname,datein,message,testim) values('$firstname','$lastname','$datein','$message','$testim')");
echo "<p>Thank you for taking the time to sign the Guestbook.</p>";
setcookie('tntcon','');
}
}
Any ideas?
Thanks for your help



