a href with header

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
lulon83
Forum Newbie
Posts: 1
Joined: Tue Jul 29, 2008 7:08 am

a href with header

Post by lulon83 »

I need help please.

I have one page on which I have an <a href="control.php">
In control.php I have to do some "things" with the datas and the database, and then I have to redirect to the <a href>.

This is what I though:

first_page
<a href="control.php?link=www.google.com">google</a>

control.php
...control of the data...
Header

My question is, how do I have to do the header? Any other solution?

Thank you.
User avatar
it2051229
Forum Contributor
Posts: 312
Joined: Tue Dec 25, 2007 8:34 pm

Re: a href with header

Post by it2051229 »

I dont get what you're trying to do.. header? the header has a lot of functions like redirecting, caching, xml contents blah blah blah.. what are you trying to achieve?
User avatar
Bill H
DevNet Resident
Posts: 1136
Joined: Sat Jun 01, 2002 10:16 am
Location: San Diego CA
Contact:

Re: a href with header

Post by Bill H »

If you're trying to redirect the user after processing data, then:

Code: Select all

header("Location:http://www.google.com");
However, be aware that no output may be sent to the browser before this function call, so all the processing needs to be data/server processing and not browser processing.
And you should call exit(); right after it to terminate the script if there is any code after the call.
User avatar
Chalks
Forum Contributor
Posts: 447
Joined: Thu Jul 12, 2007 7:55 am
Location: Indiana

Re: a href with header

Post by Chalks »

Bill H wrote:you should call exit(); right after it to terminate the script if there is any code after the call.
In my code, I've been using die(). Any reason to go back and change it to exit()?
el_taco
Forum Newbie
Posts: 1
Joined: Tue Jul 29, 2008 10:59 pm

Re: a href with header

Post by el_taco »

die() and exit() are essentially the same.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: a href with header

Post by RobertGonzalez »

Please post threads in the appropriate forum. This one was moved from General Discussion to PHP Code.
Post Reply