jbingman Posted September 25, 2007 Share Posted September 25, 2007 Can you save a header() into a variable or is there a way to use that same header more than once on a page? Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/ Share on other sites More sharing options...
trq Posted September 25, 2007 Share Posted September 25, 2007 A call to header returns void. You need to explain exactly what it is your trying to do. Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-355344 Share on other sites More sharing options...
jbingman Posted September 25, 2007 Author Share Posted September 25, 2007 im creating a CMS and i want im using a $_GET variable for each page and all the code is in one file. once they click the save button in the CMS i want it to insert the data into the database(which ive already finished) but i want them to go to an "Update Success" page after they click save. I want each page to go to the same "header()" Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-355354 Share on other sites More sharing options...
jbingman Posted September 26, 2007 Author Share Posted September 26, 2007 Does anyone have any idea how to do this? Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-355431 Share on other sites More sharing options...
cooldude832 Posted September 26, 2007 Share Posted September 26, 2007 use ajax Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-355432 Share on other sites More sharing options...
chronister Posted September 26, 2007 Share Posted September 26, 2007 Throw the header() code into a user-defined function. Then call that function when you need to. dunno if this helps or not, but anytime I need to reuse code, thats what I would do. Â Nate Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-355493 Share on other sites More sharing options...
jbingman Posted September 26, 2007 Author Share Posted September 26, 2007 Yeah, the problem is i dont know ajax and i really dont want to get into it right now because im still at the beginning of PHP. Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-356041 Share on other sites More sharing options...
trq Posted September 27, 2007 Share Posted September 27, 2007 I want each page to go to the same "header()" Â Can you explain exactly what you think a header is? Do you mean a call to php's header function or are you talking about what is between html's <head> tag? Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-356129 Share on other sites More sharing options...
cooldude832 Posted September 27, 2007 Share Posted September 27, 2007 Thorpe has a valid point here, and the header() function sends raw header data to the browser for its uses. Such as a 404 for a page not found error. This is useful in multiple ways. 1) send errors like 404 2) send header(location: page.php); to redirect 3) send data about what the document type is. This is key in a lot of cases as you don't want the default xhtml doc type sent 4) Send detailed info about the page (Such as a pdf for download vs in browser display)  and many more as explained here http://us.php.net/manual/en/function.header.php  you can send multiple headers, if they make sense, but I don't think your using the term right as thrope suggested Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-356150 Share on other sites More sharing options...
jbingman Posted September 27, 2007 Author Share Posted September 27, 2007 Yeah i want to use it as a (location: ) function. Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-356834 Share on other sites More sharing options...
d22552000 Posted September 27, 2007 Share Posted September 27, 2007 $loc = 'index.php'; header('Location: '.$loc); Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-356835 Share on other sites More sharing options...
MadTechie Posted September 27, 2007 Share Posted September 27, 2007 I want each page to go to the same "header()" Yeah i want to use it as a (location: ) function.  Am i missing something here ?  so everypage goes to the same page!!! ???  please re-phrase what your goal is ! Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-356846 Share on other sites More sharing options...
d22552000 Posted September 27, 2007 Share Posted September 27, 2007 good idea  *WOOOOOOT* 399 Posts Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-356847 Share on other sites More sharing options...
chronister Posted September 28, 2007 Share Posted September 28, 2007 <?php  function location()  {    header('Location:http://www.yoursite.com/somepage.php');  } ?>  and anytime you wanna use it just call it....  <?php location(); ?>  and you cannot use a header-location more than once on a page because the first time the script hits the header(); it will redirect and your no longer on that page.  I guess this saves a little typing .... but not much.. Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-356994 Share on other sites More sharing options...
jbingman Posted September 28, 2007 Author Share Posted September 28, 2007 Yeah, so like i said above my goal is to have all the pages on the admin area behind $_GET variables. When they finish editing whatever page they selected they get sent to the success page. Thanks everyone for you help. Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-357578 Share on other sites More sharing options...
trq Posted September 29, 2007 Share Posted September 29, 2007 I think you should read the how to ask... link in mysigniture. Quote Link to comment https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-357624 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.