Page 1 of 1

a href with header

Posted: Tue Jul 29, 2008 7:14 am
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.

Re: a href with header

Posted: Tue Jul 29, 2008 9:07 am
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?

Re: a href with header

Posted: Tue Jul 29, 2008 11:35 am
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.

Re: a href with header

Posted: Tue Jul 29, 2008 8:01 pm
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()?

Re: a href with header

Posted: Tue Jul 29, 2008 11:03 pm
by el_taco
die() and exit() are essentially the same.

Re: a href with header

Posted: Thu Jul 31, 2008 12:17 pm
by RobertGonzalez
Please post threads in the appropriate forum. This one was moved from General Discussion to PHP Code.