FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


PHP how to refresh to some URL according to *.php?id=xxxx





takashiro
I once use this:
<?php
$id=$GET['id'];
switch($id)
{
default:
header("Status: 404 Not Found");
break;
case music:
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=http://popmusic.com/\">";
break;
}
?>

I did not know what is wrong. *.php?id=music does not work.
Roald
It must be
Code:
case "music":
....
Otherwise php won't see it as text.
DanielXP
Code:
<?php
$id=$GET['id'];
switch($id)
{
default:
header("Status: 404 Not Found");
break;
case "music":
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=http://popmusic.com/?id=" . $id . "\">";
break;
}
?>


Some thing like that?
Roald
I think that should work.
coeus
Needs to be $_GET not $GET
So it should be:
Code:

<?php
$id=$_GET['id'];
switch($id)
{
default:
header("Status: 404 Not Found");
break;
case "music":
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=http://popmusic.com/?id=" . $id . "\">";
break;
}
?>
Roald
Damn why didn't I see that?
BlueVD
and you can replace
Code:
echo "<META HTTP-EQUIV=\"refresh\" CONTENT=\"0;url=http://popmusic.com/?id=" . $id . "\">";
with
Code:
header('Location: http://popmusic.com/?id='.$id);

It's better to make it with header redirects than with META tags.
takashiro
Thank you! It works well now! I will be more careful next time.
manum
location header is always better i guess and do remember to send all headers before printing ny text
Related topics
Theft story...
php variables
PHP Toturail
How To : Improve Your PHP Programming
Themes para Php Nuke o Platinum
News and Comment system!
PHP - Error
Forum Avatar error
Something crazy about IE javascript wew...
What a Heck with javascript..
Generating the next shade of a colour.
Problem with Member system(or template) and $_GET[id]
Relatively Secure Session Management System for PHP
how to create post views?
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.