Page 1 of 1

Header not working???

Posted: Sat Nov 04, 2006 12:32 am
by cturner
Can someone please tell me how I can place a database table item in a header like below? I have placed ?username=.$row[username] into the header but when it is time to go to viewcart.php it displays viewcart.php?username=.$row[username] in the location box in the web browser. I need the username from the database table to be displayed after ?username=.

Code: Select all

header ('Location: viewcart.php?username=.$row[username]');
Thanks in advance.

Posted: Sat Nov 04, 2006 12:59 am
by nickvd
Try

Code: Select all

header ('Location: viewcart.php?username=' . $row['username']);

Posted: Sat Nov 04, 2006 1:18 am
by cturner
I have tried what you posted nickvd but now it is displaying viewcart.php?username= in the location box in the web browser.

Posted: Sat Nov 04, 2006 1:23 am
by nickvd
Just to make sure, since you haven't posted much code (hint, hint) ... You are making a database query to retrieve the data you wish to output right?

Posted: Sat Nov 04, 2006 7:10 am
by feyd
...and remember to use full URLs in header redirections. http://domain/path/etc and all.

Posted: Sat Nov 04, 2006 7:30 am
by Cameri
feyd wrote:...and remember to use full URLs in header redirections. http://domain/path/etc and all.
O_Ou?

I've used relative URLs with the header() function in almost all my applications :s, why is that?
Do I have to change all of them to absolute URLs?

Posted: Sat Nov 04, 2006 7:35 am
by feyd
Yes, you do.

HTTP standard compliant agents will not be able to follow any relative references.

viewtopic.php?t=43364