Jump to content

Recommended Posts

I run a site and every so often I'll check the user to make sure they are not a program by displaying an image using GD and have them click the button that matches the image.

Heres the image generation code.

[code]$image = imagecreate(140, 30);

$white = imagecolorallocate($image, 255, 255, 255);
$gray = imagecolorallocate($image, 210, 210, 210);
$black = imagecolorallocate($image, 0, 0, 0);

$string = "text code pulled from database here";


for ($i=0; $i<25; $i++) {
  $x1 = rand(0,140);
  $y1 = rand(0,30);
  $x2 = rand(0,140);
  $y2 = rand(0,30);
  imageline($image, $x1, $y1, $x2, $y2 , $gray); 
}


$size = rand(4, 5);
$x = rand(12 , 80);
$y = rand(7 , 12);
 


imagestring($image, $size, $x, $y, $string , $black);

imagepng($image);
imagedestroy($image);
[/code]

I call this page by doing this:

[code] <img src=\"page.php?user=$userid\"/>[/code]

This works for the most part.

It works great for me and does great for some of my users but some are reporting that sometimes the image doesn't match up to the choices. I can't get it to do it on me so I'm thinking it could be something to do with the cache settings on their browsers.

Am I using the image correct? Any ideas on what could be causing this?
Link to comment
https://forums.phpfreaks.com/topic/13299-gd-image-issue/
Share on other sites

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.