Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.