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
cturner
Forum Contributor
Posts: 153 Joined: Sun Jul 16, 2006 3:03 am
Location: My computer
Post
by cturner » Sat Nov 04, 2006 12:32 am
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 » Sat Nov 04, 2006 12:59 am
Try
Code: Select all
header ('Location: viewcart.php?username=' . $row['username']);
cturner
Forum Contributor
Posts: 153 Joined: Sun Jul 16, 2006 3:03 am
Location: My computer
Post
by cturner » Sat Nov 04, 2006 1:18 am
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 » Sat Nov 04, 2006 1:23 am
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Nov 04, 2006 7:10 am
...and remember to use full URLs in header redirections.
http://domain/path/etc and all.
Cameri
Forum Commoner
Posts: 87 Joined: Tue Apr 12, 2005 4:12 pm
Location: Santo Domingo, Dominican Republic
Post
by Cameri » Sat Nov 04, 2006 7:30 am
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?
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Nov 04, 2006 7:35 am
Yes, you do.
HTTP standard compliant agents will not be able to follow any relative references.
viewtopic.php?t=43364