This is a discussion on "[SOLVED] header location" within the PHP Forum section. This forum, and the thread "[SOLVED] header location are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
[SOLVED] header location
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
||||
|
[SOLVED] header location
I know headers have got to be before any output to the browser but I have finally come up against a problem where i need to use header ( "Location:
This is a very cut down version of the layout for my site and you can see that I have a switch that gets the page from the url and includes that page for display
Is there any way I can get around this? |
|
|
|
||||
|
Re: header location
Well, you could use a javascript redirect.....
Otherwise you are going to have to include your pages before you output anything.
Last Blog Entry: 10 Reasons Why My Laptop Is Better Than Your Girlfriend (Dec 15th, 2007)
|
|
||||
|
Re: header location
You could use output buffering. This will store all of the output until requesting it be sent to the page.
put ob_start(); at the top of your script and ob_end_flush(); when you know you won't have to change the headers after that point. This will allow you to send headers after 'writing' to the output buffer. Cheers
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
||||
|
Re: header location
There's no big issue with using output buffering and it gives you the ability to perform functions on ALL the data before outputing it.
The problem comes when you have a large page and you're storing it in a buffer. Imagine a large page being hit by 100 users at once -- could bring down a shared server for a time. In most cases though there is more advantages than not.. I rarely use it as I usually send all headers before outputting anything.. It would be coding prefence really.
Last Blog Entry: The wannabe juggler's quest (Oct 27th, 2007)
|
|
||||
|
Re: header location
Quote:
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: header location
Would this work?
At the top of the page put this
|
|
||||
|
Re: header location
PHP checks in a logical order, top to bottom.
So I don't think that will work if $location is below the if statement.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: header location
What about this?
|
|
||||
|
Re: header location
That would work.
The form could be on another page, which links to this page or you could use GETs.
Last Blog Entry: 3D Chess in your browser! (Mar 14th, 2008)
|
|
||||
|
Re: header location
I have been ooing and ahhing about using the above solution and there are instances where i think it wouldn't work whcih is a pain. I want to try and make my code as efficient as poosible (possibly getting it drilled into us at college and uni).
Can someone please provide and example of a basic contact form or another page which uses a browser redirect so i can sede how it's done? The ob_start() and ob_flush() works fine and that's fine for what i'm doing now but I want to try and get up to scratch with php and the proper procedures as I am thinking of doing my final year project at uni, a website that uses php and I'm going to need OOP and the correct way of doing things as I'm sure they're going to be reading the code |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| [SOLVED] Problems with CSS 'Header Image' - How to make fluid?? | slimboyfatz32 | Web Page Design | 5 | Jan 28th, 2008 09:09 |
| co-location | tankara | Hosting & Domains | 5 | Jan 18th, 2008 07:54 |
| [SOLVED] User Location | Monie | Classic ASP | 3 | Jan 8th, 2008 00:55 |
| Search by location | andrwcris | Website Planning | 1 | Sep 11th, 2007 17:33 |
| Need to Trace this Location Map | davva | Graphics and 3D | 4 | Aug 31st, 2006 19:08 |