crimsonmoon Posted June 30, 2006 Share Posted June 30, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/13299-gd-image-issue/ Share on other sites More sharing options...
Barand Posted June 30, 2006 Share Posted June 30, 2006 Your image script needs header("content-type: image/png") before the imagepng() call.Also I was under the impression that dynamic images aren't cached.You don't seem to do anything with the "?user=$userid" either Quote Link to comment https://forums.phpfreaks.com/topic/13299-gd-image-issue/#findComment-51280 Share on other sites More sharing options...
crimsonmoon Posted June 30, 2006 Author Share Posted June 30, 2006 I tried adding the header...I do something with it I just didn't show it.THX! Quote Link to comment https://forums.phpfreaks.com/topic/13299-gd-image-issue/#findComment-51299 Share on other sites More sharing options...
crimsonmoon Posted July 4, 2006 Author Share Posted July 4, 2006 Well still no luck. I even redesigned my script to pull a code from the DB to display that only changes once per hour. It's working for most but I still get a small group where it doesn't.It almost has to be a caching issue.Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/13299-gd-image-issue/#findComment-52854 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.