Jump to content


Photo

php generated forms not refreshing html img tag


  • Please log in to reply
8 replies to this topic

#1 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 21 September 2006 - 04:30 AM

Hi, I have a same-page form-display script that calls a function to generate a jpg. If the form hasn't been filled in it shows a default .jpg. The trouble is that when the submit button is pushed and the new .jpg is created the page itself doesn't change to show the new image. Is there a php solution or do I have to use javascript? 

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 21 September 2006 - 08:46 AM

The problem is that cos the image is the same name, then when the users machine reads the data, it see's it has the image on the users machine

Simple solution, is to stop the cache

this is HTM META tag, place in the head of your wesbite

<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

Tell me the problem, I will try tell you the solution

#3 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 21 September 2006 - 08:58 AM

Thanks for the reply and it was a help, but default.jpg and the target.jpg did have different names. (Which was the bit that weirded me out). Your code does make the browser distinguish between default.jpg and target.jpg but if I update target.jpg with the same form it takes a manual refresh for the page to notice the difference.
 

#4 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 21 September 2006 - 09:20 AM

PHP is Server Side Coding, Nothing will change without a Page Refresh
Try Client side Coding, such as Javascript
Tell me the problem, I will try tell you the solution

#5 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 21 September 2006 - 09:26 AM

Got that, just trying to see if there was a non-javascript solution given that there is a form action going on and the page is renewing itself at least partially. I'm trying to understand why the page will not fully renew itself as the Headers for the target.jpg change on submit, but not the image itself. Even with the caching turned off.

#6 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 21 September 2006 - 09:31 AM

Actually above solution works for firefox, now guessing it's a case of Internet Explorer just being Internet Explorer.

#7 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 21 September 2006 - 10:31 AM

There is a setting in IE, which says if it should grab the images again, or use the system images

This is a nightmare, when working with GD Lib, as if your cropping / resizing images, it uses the local file, not the server file

To change this (for note)
On the File, Edit, View...
Click
Tools -> Internet Options

Then in the middle of the screen says, Temporary Internet Files,
and a button for Settings
Click Settings

Then you should have some radio buttons at the top,
My Default, this is set to Automatically.
Change this to
Every visit to every page

Solves the problem every time
But unless you want to tell your users to do this, I dont know
Tell me the problem, I will try tell you the solution

#8 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 21 September 2006 - 11:03 AM

If you are able to name an image 'default.jpg?random_number_of_some_sort' then the browser will think it is different from any other 'default.jpg' in the cache and load a fresh version.
Legend has it that reading the manual never killed anyone.
My site

#9 warewolfe

warewolfe
  • Members
  • PipPipPip
  • Advanced Member
  • 57 posts
  • LocationOtago, NZ

Posted 21 September 2006 - 07:16 PM

Thanks for the help, I'm going to autoincrement the target image's name with "target$var.jpg" to get the same effect as a fresh name but still be able to show the image within an html tag.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users