Forum Moderators: coopster

Message Too Old, No Replies

header function disfunction

         

kumarsena

5:44 pm on Jan 9, 2004 (gmt 0)

10+ Year Member



hey guys
i got this script here that refuses to work as i intended. it registers a session key and then redirects the user to a welcome page. all this after choosing form a form and clicking a link/button. but the redirection does not work, keeps coming back to page where the user selects from a form and submits (the first page from which the script is called). any help?

<?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://localhost/welcome.php3');
?>

justageek

7:57 pm on Jan 9, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try this:

header("Location: [localhost...]

I'm assuming when you put localhost in there it was just for this post...right? If not then it would confuse the browser.

JAG

kumarsena

3:42 pm on Jan 10, 2004 (gmt 0)

10+ Year Member



thanks, that works!
but why?

well i have a website up and running, but the there is also a local version, therefor localhost. why would it confuse the browser....... the thing is it worked before, the same header location thing, wheni was using cookies instead of cookies.

thanks!

kumarsena

3:45 pm on Jan 10, 2004 (gmt 0)

10+ Year Member



well not really,

it worked on localhost..but not on the server. i changed the location to the web adress but it keeps reloading the first page.
any idea what is going on?

justageek

3:46 pm on Jan 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Headers can be funny sometimes. The only thing that is different now is the space after location:.

JAG

justageek

3:48 pm on Jan 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Post exactly what you have now.

JAG

kumarsena

3:56 pm on Jan 10, 2004 (gmt 0)

10+ Year Member



this is what i have on localhost now, and it works.

header("Location:welcome.php3");

but if i change it to

header("Location:http://localhost/welcome.php3");

it does not. with and without eh space after location

justageek

4:01 pm on Jan 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hmmm. Should work. If you copy the exact url into your browser do you get there? I'm thinking the Location page may not be on the server? Just a thought.

JAG

kumarsena

4:02 pm on Jan 10, 2004 (gmt 0)

10+ Year Member



actually it does work this line

header('Location: [localhost...]

i just forgot the sub folder..it works both with double quotes and single quotes and space and no spcae as long as it is on localhost.

but still problme with the online wesion

kumarsena

4:04 pm on Jan 10, 2004 (gmt 0)

10+ Year Member



well it doesnt..copying the url to browser.
the welcome.php3 file is there..just that it load...

kumarsena

4:05 pm on Jan 10, 2004 (gmt 0)

10+ Year Member



dont know if it has anything to do with ti, but on top of welcome.php3 this code is there

<?php

session_start();

header("Cache-control: private"); // IE 6 Fix.

?>

would that have anything to do with it....?

justageek

4:06 pm on Jan 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Sticky me the exact header and real location and I'll try it on my machine.

JAG

justageek

4:08 pm on Jan 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Remember that you cannot output anything before the header.

JAG

kumarsena

4:13 pm on Jan 10, 2004 (gmt 0)

10+ Year Member



the thing is if i do like this on the server

header("Location: welcome.php3");

it works, the welcome page loads, but the skin/session var is not loaded....

justageek

4:29 pm on Jan 10, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK. I ran your code locally and it is fine. I'm stumped. There is something on the php web site in the session_start function area about some strangeness on certain configurations. Look about half way down the page.

JAG

kumarsena

4:55 pm on Jan 10, 2004 (gmt 0)

10+ Year Member



ok thanks

kumarsena

11:49 pm on Jan 10, 2004 (gmt 0)

10+ Year Member



im still having problems with this stuff,, so if anyone has got anything to add, i would be glad....

thanks

kumarsena

4:52 pm on Jan 11, 2004 (gmt 0)

10+ Year Member



u guys know what? i might just be the biggest idiot on the planet....

i had made changes to the local verison of the site, and had moved skins into a new folder.....guess what...i forgot to upload this folder to the server,, so there was a reference to a non-exsisting folder.....thats why the whole problem...the thing is now...if i use

header("Location: welcome.php3");

it works fine...no probs at all, but if i use

header("Location: [domain.tk...]

then it reloads the index page aagain...

i had tried the first option but since the skin wasnt loading i figured the session wasnt maybe set.....

but anyway just wondering,,,,why the reload, when using full url?

anyways.....thanks for all the help

kumar

justageek

5:02 pm on Jan 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



u guys know what? i might just be the biggest idiot on the planet....

Idiot? Nope. We all make those mistakes :-)

header("Location: [domain.tk...]

Is your welcome.php3 in your earthsoul directory? If so then you need to add it to the url.

JAG

kumarsena

9:10 pm on Jan 11, 2004 (gmt 0)

10+ Year Member



no its in the root on the server...
anyways im going back to cookies for a while till i get this sorted...