It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming PHP and MySQL Forum

Image Verification

Moderator: Malcolm

Re: Image Verification

Postby rangana on Thu Mar 19, 2009 4:18 am

I'll stick on Adam's rendition.

- Use || in replacement of or.
- Use && in replacement of and.
- Use != in replacement of <>.

One last thing, I might be at mistake, but try to change this part:
Code: Select all
if(md5($verification).'a4xn' != $_COOKIE['tntcon'])


...into:
Code: Select all
if((md5($verification).'a4xn') != $_COOKIE['tntcon'])


Hope it helps.
User avatar
rangana
500+ Club
 
Posts: 935
Joined: Wed Feb 27, 2008 5:14 am
Location: Cebu City Philippines

Re: Image Verification

Postby dflynn on Thu Mar 19, 2009 4:21 am

I'm still getting the "Please make sure your Verification Code is correct. " line. :S


hmmm.
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: Image Verification

Postby dflynn on Thu Mar 19, 2009 4:22 am

Oh, didn't see Rangana's post. I'll try that.
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: Image Verification

Postby dflynn on Thu Mar 19, 2009 4:23 am

Still no luck
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: Image Verification

Postby rse on Thu Mar 19, 2009 4:28 am

I will send you a full script which should work.

I stripped out the SQL part in my example but the rest should be the same.

I'll get back to you shortly.
Adam Williams
PHP Web Developer

Personal: http://30things.net
Blog: http://www.root-servers.co.uk
User avatar
rse
100+ Club
 
Posts: 141
Joined: Sun Oct 10, 2004 8:15 pm
Location: Leeds, UK

Re: Image Verification

Postby dflynn on Thu Mar 19, 2009 4:29 am

ok thanks again.
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: Image Verification

Postby rse on Thu Mar 19, 2009 4:34 am

Code: Select all
<?php
$todo = $_REQUEST['todo'];
$firstname = $_REQUEST['firstname'];
$lastname = $_REQUEST['lastname'];
$message = $_REQUEST['message'];
$testimonial = $_REQUEST['testimonial'];
$verification = $_REQUEST['verification'];

if(isset($todo) and $todo=="post") {

$status = "OK";
$msg="";

if(!isset($firstname) || strlen($firstname) <2){
$msg=$msg."Your first name should be at least 2 characters long. <br />";
$status= "NOTOK";}

if(!isset($lastname) || 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','');
}
}

echo "<p>Debugging info:</p>";
echo "<p>Submitted verification: ".$verification."</p>";
echo "<p>Required verification: ".$_COOKIE['tntcon']."</p>";

?>

<h2>Sign The Guestbook</h2>
Please fill out ALL fields before submitting. Thank you.<br /><br />
<form name="form1" method="post" action="process.php" 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="image.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>


I've added debugging info at the bottom which hopefully will point out any further issues.

I hope this helps.

Let me know.

Ads
Adam Williams
PHP Web Developer

Personal: http://30things.net
Blog: http://www.root-servers.co.uk
User avatar
rse
100+ Club
 
Posts: 141
Joined: Sun Oct 10, 2004 8:15 pm
Location: Leeds, UK

Re: Image Verification

Postby dflynn on Thu Mar 19, 2009 4:43 am

So, in the debugging, it's not returning the image code from the cookie. The cookie is being stored no problem, it's just doesn't seem to find it.
Any ideas?
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: Image Verification

Postby dflynn on Thu Mar 19, 2009 4:43 am

http://www.nnjoi.com/shannon/guestbook.php
The link if you wanna test it out.
User avatar
dflynn
500+ Club
 
Posts: 860
Joined: Wed Oct 03, 2007 9:06 pm
Location: Guelph, Canada

Re: Image Verification

Postby rse on Thu Mar 19, 2009 4:50 am

if you add print_r($_COOKIE); below the other debugging lines what does it show?

Cheers
Adam Williams
PHP Web Developer

Personal: http://30things.net
Blog: http://www.root-servers.co.uk
User avatar
rse
100+ Club
 
Posts: 141
Joined: Sun Oct 10, 2004 8:15 pm
Location: Leeds, UK

PreviousNext

Who is online

Users browsing this forum: No registered users and 0 guests