Header not working???

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

Header not working???

Post 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.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post by nickvd »

Try

Code: Select all

header ('Location: viewcart.php?username=' . $row['username']);
User avatar
cturner
Forum Contributor
Posts: 153
Joined: Sun Jul 16, 2006 3:03 am
Location: My computer

Post 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.
nickvd
DevNet Resident
Posts: 1027
Joined: Thu Mar 10, 2005 5:27 pm
Location: Southern Ontario
Contact:

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

...and remember to use full URLs in header redirections. http://domain/path/etc and all.
User avatar
Cameri
Forum Commoner
Posts: 87
Joined: Tue Apr 12, 2005 4:12 pm
Location: Santo Domingo, Dominican Republic

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Yes, you do.

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

viewtopic.php?t=43364
Post Reply