Jump to content

Is this Image Verification Code Valid??


phpSensei

Recommended Posts

I looked at no tutorials, and I tried to set a challenge for myself...

 

I was wondering how everytime I refresh the page on a site, and the image of the verification code changes, and when validating the field where the code is inserted, The Field must match the image....

 

My problem is, if there is a much more simpler way of doing this...

 

Images Directory

 

/imgs/img.gif

/imgs/img2.gif

/imgs/img3.gif

 


<?php

$images = array("img","img2","img3");

shuffle($images);

echo '<table width="22%" height="19" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td width="22%"><div align="center"><img src="  '.$images[0].'  .gif" name="img" id="img"/></div></td>
    <td width="78%"><form name="form1" method="post" action="">
      <label>
      <input type="text" name="code" id="code">
     <input name="verification" type="hidden" id="verification" value="'.$images[0].'">
      </label>
            </form>    </td>
  </tr>
</table>
';

?>

 

 

VALIDATING THE FORM

 


<?php



$code = $_POST['code'];
$imgtype = $_POST['verification'];

if(($imgtype == "img")||($imgtype == "img2")||($imgtype == "img3")){
if($imgtype == "img"){

$verification = "123";

}
elseif($imgtype == "img2"){

$verification = "246";

}
else
{

$verification = "543";

}

//////// End Code

if($code <> $verification){

die("sorry, wrong code...");

}
}
else
{
die("code does not exist");
}
?>


Link to comment
https://forums.phpfreaks.com/topic/67940-is-this-image-verification-code-valid/
Share on other sites

whats wrong with my script? (Even though the same image might come up twice, but what are the chances of that since i will have around 30 of them, or more...). I also know what Captcha is...

 

why don't people just use the same method as I do.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.