strange header location error
Moderator: General Moderators
strange header location error
hi,
i ahve the code as below, but instead of redirecting to given url, the script rather reloads the index page where the user makes the selction.. how come. it is working fine on localhost, but not on the server...
any ideas....it was working fine while i was using cookies, but when i moved to sessions it started acting like taht.
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix.
// Get the user's input from the form
$skin = $_POST['skin'];
// Register session key with the value
$_SESSION['name'] = $skin;
header("Location: http://www.domain.tk/welcome.php3");
?>
i ahve the code as below, but instead of redirecting to given url, the script rather reloads the index page where the user makes the selction.. how come. it is working fine on localhost, but not on the server...
any ideas....it was working fine while i was using cookies, but when i moved to sessions it started acting like taht.
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix.
// Get the user's input from the form
$skin = $_POST['skin'];
// Register session key with the value
$_SESSION['name'] = $skin;
header("Location: http://www.domain.tk/welcome.php3");
?>
well i ahve tried removing the first header,,,,,
but still same problem....works on localhost....
but if i redirest to the same file on server using full url. it opens the index.html file but the address bar shows ...welcome.php3...now i find that pretty weird...
basically this is my problem:
user goes to index.html chooses a skin. this is saved in a session then the user is redirected to welcome.php3. it worked fine while i was using cookies, but with sessions i cannot get it to work...
any help to solve this problem would help.
but still same problem....works on localhost....
but if i redirest to the same file on server using full url. it opens the index.html file but the address bar shows ...welcome.php3...now i find that pretty weird...
basically this is my problem:
user goes to index.html chooses a skin. this is saved in a session then the user is redirected to welcome.php3. it worked fine while i was using cookies, but with sessions i cannot get it to work...
any help to solve this problem would help.
It might be useful to see some more of your code... now that you've mentioned sessions() you might have a problem with those and not the actual page redirection.
Also when using header() to redirect to your own website pages you shouldn't have to use the full url as it can be used as a relative redirection... ie header("page2.php") or header("../page2.php") and so on.
Also when using header() to redirect to your own website pages you shouldn't have to use the full url as it can be used as a relative redirection... ie header("page2.php") or header("../page2.php") and so on.
well, this is how it goes..
the code on top is the code i use to set the session...the user calls it after choosing the skin on the index.html page. the on every page that i use the skin i include the following script..
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix.
?>
then the following to use the skin
<link rel="stylesheet" href="<? echo $_SESSION['name'];?>" type="text/css">
and thats it...
the code on top is the code i use to set the session...the user calls it after choosing the skin on the index.html page. the on every page that i use the skin i include the following script..
<?php
session_start();
header("Cache-control: private"); // IE 6 Fix.
?>
then the following to use the skin
<link rel="stylesheet" href="<? echo $_SESSION['name'];?>" type="text/css">
and thats it...
The IE6 bug is about messages as "Want to refresh data" and it's likes when presing the back button after submitting a form (as well as issues saving the forms entered data while doing the same).Gen-ik wrote:True, but there are a lot of things in tutorials which aren't always needed. All I was saying is that I've never needed to use it... and I use IE6 all the time.
Yes, might work for you, but you are perhaps 2% of the IE users not affected, so i'd still recommend using it along with other no-caching headers. It's not vital to get things to work, it merely removes certain unwanted sideeffects.
Headers works just fine. Why use javascript?Pyrite wrote:Don't use the header() function for redirection or the HTML meta tag either.
Use Javascript.
@kumarsena:
Code: Select all
// change
$_SESSION['name'] = $skin;
header("Location: http://www.domain.tk/welcome.php3");
//to
$_SESSION['name'] = $skin;
print_r($_SESSION);
//header("Location: http://www.domain.tk/welcome.php3");