469,271 Members | 1,431 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,271 developers. It's quick & easy.

Meta Refresh does not pass on PHP variable?

I'm trying to get a meta redirect to pass on a php variable to the redirected page, using the $_GET method.

I have the mypage.php?user=created&username=$name&comment=$co mment etc

, but ONLY the first 'user=created' seems to be passed on.

All the other in line, like the username=$name comes from a script where this meta refresh is used, at the bottom.
The script uses sessions, but it never sends the other variables.
Not the original or simple test variables.

The variables does echo during the script, so it must be the meta refresh that are stopping them.

Is this a common problem, or can I fix this somehow?
Jan 2 '10 #1
12 7525
Dormilich
8,651 Expert Mod 8TB
hard to tell without something to look at.
Jan 2 '10 #2
I thought this could be a standard issue, but here is the script stuff:

Expand|Select|Wrap|Line Numbers
  1.         echo "<meta http-equiv='Refresh' content='1;url=mypage.php?user=created&username=$name&password=$pw2&comment=$comment&accesslevel=$accesslevel#msg'> ";

all variables are defined like: $comment=$_POST["comment"];
Everything is sent from a submit form on the same page returning to via the meta refresh.
The URL dont even have the variables filled, so it seems like the meta refresh stops php or something.

Using a different method where i would use $url and echo $url; inside the meta refresh area didnt work. The browser simply said that $url was not found, even though it was defined as a whole url above the meta refresh :/
Jan 2 '10 #3
Dormilich
8,651 Expert Mod 8TB
The URL dont even have the variables filled, so it seems like the meta refresh stops php or something.
due to PHP being a server side language, it has finished working before the HTML is sent to the browser.

what does the meta tag in the HTML look like? (increase the refresh delay sufficiently)
Jan 2 '10 #4
In the sourcecode during the script, it looks like this:

<meta http-equiv='Refresh' content='10;url=mypage.php?user=created&username=b ob&password=bobpw&comment=bobcmt&accesslevel=2#msg '>


So believe it or not, the whole thing actually worked when I increased the refresh delay from 1 to 10.
Does the script need more time than 1 second perhaps? Sounds so strange.
Jan 2 '10 #5
Dormilich
8,651 Expert Mod 8TB
as I already mentioned, the script usually finishes first, before sending the output.
Jan 2 '10 #6
I guess we can say it is working, it just needed 2 seconds to work it seems.

Anyway thanks for the help!
I wouldn't have discovered it if you didn't tell me to increase the refresh delay =)
Jan 2 '10 #7
Dormilich
8,651 Expert Mod 8TB
why do you need the refresh anyway? you could instantly forward using header("Location: $url").
Jan 2 '10 #8
Got a header error :p
Jan 2 '10 #9
Dormilich
8,651 Expert Mod 8TB
this may well be if you’ve never worked with headers before.
Jan 2 '10 #10
I have them lots of places, but I'm not familiar with the technical reasons for the errors themselves, though I've had them before (the errors).

I heard whitespace could be a cause for this error, but in this case it looks fairly implausible.
Jan 2 '10 #11
Your header() probably throws a warning (not an error) because there was already output from the PHP script. Since HTTP headers (that's what it is) must be outputed before any other content, the header command must be given before any output command (like echo/print).
Whitespace is indeed a possibility. Why is that so implausible? Also possible is you just echo'ed something already. You can see that in your HTML (especially then the delay is 10 sec).

Also, I don't believe it matters whether the delay is 0, 1, 2 or 10 seconds. PHP doesn't care about that value. The correct HTML should be printed whatever the HTML is.

Try this (it's neater, if nothing else):
Expand|Select|Wrap|Line Numbers
  1. echo '<meta http-equiv="refresh" content="1;url=mypage.php?user=created&amp;username='.$_POST['name'].'&amp;password='.$_POST['pw2'].'&amp;comment='.$_POST['comment'].'&accesslevel='.$_POST['accesslevel'].'#msg" />';
Jan 2 '10 #12
Markus
6,050 Expert 4TB
See this unfinished article.
Jan 2 '10 #13

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by Artificial Life | last post: by
43 posts views Thread by dan baker | last post: by
14 posts views Thread by Shiperton Henethe | last post: by
12 posts views Thread by Tarken | last post: by
2 posts views Thread by Prodip Saha | last post: by
4 posts views Thread by aaa | last post: by
1 post views Thread by joeblast | last post: by
1 post views Thread by helraizer1 | last post: by
41 posts views Thread by Twayne | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.