Jump to content

Multiple Header


jbingman

Recommended Posts

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()"

Link to comment
https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-355354
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-356150
Share on other sites

<?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..

Link to comment
https://forums.phpfreaks.com/topic/70691-multiple-header/#findComment-356994
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.