dsaba Posted March 20, 2007 Share Posted March 20, 2007 i have an image verification script that I use on a form it works fine, and displays a random string on an image the problem is when I link back to the page the last image code still shows, when in fact a new code has been generated, i have to refresh the page to actually get the image to change this also happens when i press the back button to go back to the page as well so what I need to know is: is there a way to not keep this image in the browser's memory, and force it to truly show the new image that the script produces? i tried this: header("Pragma: no-cache"); // HTTP/1.0 header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past but it doesnt' help, I appreciate some help, my script is way to complicated to post, if you need more explaining on the situation I can do that - thanks Link to comment https://forums.phpfreaks.com/topic/43568-image-stays-in-memory-image-verification-script-when-refreshing-the-page/ Share on other sites More sharing options...
per1os Posted March 20, 2007 Share Posted March 20, 2007 You can set a session variable on the "wrong" page that states $_SESSION['resetimage']; If that variable is true, re-generate the image in the script. I am not sure if it will work, but give it a try see what happens. Link to comment https://forums.phpfreaks.com/topic/43568-image-stays-in-memory-image-verification-script-when-refreshing-the-page/#findComment-211603 Share on other sites More sharing options...
dsaba Posted March 20, 2007 Author Share Posted March 20, 2007 damn this is really hard to explain and i'm usually pretty good at doing that let me just show you what I mean go to this link: http://p2mhunt.awardspace.com/submit.php there you will find a form asking you to login, all you need to do is fill in the verify code field if u fill in the wrong code it will alert you and tell you that it is the wrong code now if you're very keen you will notice that the "session code" is different than the code it originally asked you to type, this may seem like an error but it is not, I know this because when it brings you to this "wrong image verification code page" it re-makes the session and image code so it will be a different code so you know what the image below is supposed to show it tells u the newly generated code but if you look below you will still see the old image Link to comment https://forums.phpfreaks.com/topic/43568-image-stays-in-memory-image-verification-script-when-refreshing-the-page/#findComment-211609 Share on other sites More sharing options...
per1os Posted March 20, 2007 Share Posted March 20, 2007 Yea, I understood the problem. I do not think there is a fix out there. If you look at (I think) even google has that issue in gmail if you mistype your password a few times. Anyhow if someone else knows I am sure they will enlighten us. Link to comment https://forums.phpfreaks.com/topic/43568-image-stays-in-memory-image-verification-script-when-refreshing-the-page/#findComment-211614 Share on other sites More sharing options...
dsaba Posted March 20, 2007 Author Share Posted March 20, 2007 no when you sign up for a new user in yahoo and when u get the image code wrong and you press teh back button on the browser you will see a NEW image verification code so it can be done, i know yahoo uses cgi, but slashdot.org does as well Link to comment https://forums.phpfreaks.com/topic/43568-image-stays-in-memory-image-verification-script-when-refreshing-the-page/#findComment-211617 Share on other sites More sharing options...
anita999 Posted March 20, 2007 Share Posted March 20, 2007 Try looking at http://www.white-hat-web-design.co.uk/articles/php-captcha.php There is a good example there and I think it is using a jpeg image like you. It refreshes everytime. Look at CaptchaSecurityImages.php and it might help. Link to comment https://forums.phpfreaks.com/topic/43568-image-stays-in-memory-image-verification-script-when-refreshing-the-page/#findComment-211629 Share on other sites More sharing options...
dsaba Posted March 20, 2007 Author Share Posted March 20, 2007 thanks that code is helpful on that webpage however- it basically is just yet another method or script that displays a captcha like image verification, which was not my problem, improving my image verification script was not the goal the goal was how to get it to refresh automatically all the time from reading that other script on that webpage this is what I gather: 1. imagejpeg($image); they output the image directly to the browser 2. on my script I do this imagejpeg($image, "verifycode.jpeg"); so a picture file actually physically resides on the domain could anyone shed some truth to my hypothesis of doing step #1 as the only way to get it to automatically refresh??? Link to comment https://forums.phpfreaks.com/topic/43568-image-stays-in-memory-image-verification-script-when-refreshing-the-page/#findComment-211653 Share on other sites More sharing options...
calabiyau Posted March 21, 2007 Share Posted March 21, 2007 <img src="verify.png?time=<?php echo $time;?>"/><br/> do this where you call the verification image and let $time be somewhere up the page equal to a unique value like time(). This unique parameter attached to the image will force the browser to download the new image instead of using cached one. Link to comment https://forums.phpfreaks.com/topic/43568-image-stays-in-memory-image-verification-script-when-refreshing-the-page/#findComment-212107 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.