what's the simplest method of making the page refresh using PHP code?
echo a meta refresh? echo some javascript?
if neither of those is best, what is? and how would one script it?
also if it is the meta refresh, how does one script that?
thanks
what's the simplest method of making the page refresh using PHP code?
echo a meta refresh? echo some javascript?
if neither of those is best, what is? and how would one script it?
also if it is the meta refresh, how does one script that?
thanks
javascript is the worst... it is JS dependant and varies by browser. JS can also be turned off, so it's not reliable.
Use meta:
<meta http-equiv="refresh" content="5;url=newpage.php">
Must be in the head section.
Note that the 5 means five seconds... use whatever number of seconds you want, 0 for immediate.
no quote after url, any relative or absolute url will work.
Yeah, echo that: echo "...here...";
The best method is to send an http header with php. That will be even better than meta. Not sure about that code, though.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Allright, great. Thanks.
One more thing -
When the page does reload, are all of the $_POST variables cleared?
For example, i go from a post reply page, to my forums page. My forums page inputs the reply info using the $_Post variables, and then the page refreshes from a meta tag. Are those $_Post variables cleared on refresh?
I understand the question, but I'm not quite sure.
Have you noticed that when you are browsing and have just sent a form, then hit refresh, that it says "Warning: the page you are refreshing contains POST data. Refreshing will send it again"; or something.
I believe it depends on the browser.
I'm not sure if it only refreshes with post data if you do so by hitting the refresh command, rather than, for example, a meta refresh.
However, with a meta refresh, you can specify the same URL as the current page, and it won't resend the data.
<meta http-equiv="refresh" content="0">
Where 0 is the time in seconds. Since the url is omitted, it's just the current page.
That WOULD likely resend the data.
With the example from above:
<meta http-equiv="refresh" content="5;url=newpage.php">
It would just be transferred to newpage.php, whether or not it was the current page, without any post data as the meta refresh is basically equivalent to an automatic link set to be "clicked" at X seconds into the page.
Bottom line-- you can certainly insure that the data WON'T be sent again if you specify the page as a url, rather than just refreshing the current page by omitting the url attribute, but I do not know if you can guarantee that the post data WILL be sent.
*Note: POST may be complex, but GET is very easy. If your forms use the get method, the data will be appended to the end of the URL.
Refreshing or visiting index.php?var=val WILL resend the get data;
refreshing or visiting index.php will NOT resend the get data.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
The POST data is never resent.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
It definitely is if the user clicks refresh, at least in Safari and mozilla... not sure about IE.
Is this disabled, then, from automatic refreshes? Only works if it's user initiated?
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
No, the browser detects that the request required POST data and asks if the user wishes to resend it. If you use a meta refresh, the browser will simply navigate to the page to which you point it. There is no way to include POST data in the meta refresh.It definitely is if the user clicks refresh, at least in Safari and mozilla... not sure about IE.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
That is good news. Thanks Twey and djr.![]()
Ok, that makes sense then.
I know I've asked this before, but I never really got an answer, Twey. Is there any way to send the post data without sending a form?
(I suppose one could code javascript to send a hidden form when a link is clicked... that might work)
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
That's actually the simplest and most effective way of doing it. For a bit more flexibility, there's always AJAX, of course.
Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!
Bookmarks