FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » buffering to allow headers in code?
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
buffering to allow headers in code? [message #170163] Thu, 14 October 2010 13:39 Go to next message
MikeB is currently offline  MikeB
Messages: 65
Registered: September 2010
Karma: 0
Member
I'm working through my class on PHP and I tried to put information from
my sign-on process in the navbar. This didn't work well, since I had to
reload the page to see it as the navbar was constructed earlier in the
code than the signon process. (Hard to explain, as we are building a
"dynamic" web page with lots of include files to fill in the main
content portion of the page.)

My instructor suggested that I do the reload of the page via php

header("Location: index.php");

after the sign-in. To do this, I have to turn on output buffering.

I recall struggling to turn off output buffering since someone here
recommended against it.

Any thoughts on this? Is this just a "quick and dirty" bypass for my
problem, accepted practice, a really bad idea, or customary practice?

I think I can code around this with some effort by putting a switch
statement in the header of the index.php, but that may be clumsy as
parts of the same web page will then be processed in two different areas.

What to do?

Thanks for any advice.
Re: buffering to allow headers in code? [message #170164 is a reply to message #170163] Thu, 14 October 2010 13:44 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/14/2010 9:39 AM, MikeB wrote:
> I'm working through my class on PHP and I tried to put information from
> my sign-on process in the navbar. This didn't work well, since I had to
> reload the page to see it as the navbar was constructed earlier in the
> code than the signon process. (Hard to explain, as we are building a
> "dynamic" web page with lots of include files to fill in the main
> content portion of the page.)
>
> My instructor suggested that I do the reload of the page via php
>
> header("Location: index.php");
>
> after the sign-in. To do this, I have to turn on output buffering.
>
> I recall struggling to turn off output buffering since someone here
> recommended against it.
>
> Any thoughts on this? Is this just a "quick and dirty" bypass for my
> problem, accepted practice, a really bad idea, or customary practice?
>
> I think I can code around this with some effort by putting a switch
> statement in the header of the index.php, but that may be clumsy as
> parts of the same web page will then be processed in two different areas.
>
> What to do?
>
> Thanks for any advice.

Get a new instructor.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: buffering to allow headers in code? [message #170165 is a reply to message #170163] Thu, 14 October 2010 13:46 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/14/2010 9:39 AM, MikeB wrote:
> I'm working through my class on PHP and I tried to put information from
> my sign-on process in the navbar. This didn't work well, since I had to
> reload the page to see it as the navbar was constructed earlier in the
> code than the signon process. (Hard to explain, as we are building a
> "dynamic" web page with lots of include files to fill in the main
> content portion of the page.)
>
> My instructor suggested that I do the reload of the page via php
>
> header("Location: index.php");
>
> after the sign-in. To do this, I have to turn on output buffering.
>
> I recall struggling to turn off output buffering since someone here
> recommended against it.
>
> Any thoughts on this? Is this just a "quick and dirty" bypass for my
> problem, accepted practice, a really bad idea, or customary practice?
>
> I think I can code around this with some effort by putting a switch
> statement in the header of the index.php, but that may be clumsy as
> parts of the same web page will then be processed in two different areas.
>
> What to do?
>
> Thanks for any advice.

Actually, I read that wrong - sorry.

If your code is constructed properly, the header command will be sent
before any output - and no problem. If you buffer your output then send
the header command, the output won't get to the screen, anyway. So
there's no point.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: buffering to allow headers in code? [message #170166 is a reply to message #170164] Thu, 14 October 2010 13:51 Go to previous messageGo to next message
MikeB is currently offline  MikeB
Messages: 65
Registered: September 2010
Karma: 0
Member
Jerry Stuckle wrote:
> On 10/14/2010 9:39 AM, MikeB wrote:
>>
>> Thanks for any advice.
>
> Get a new instructor.
>

Wow, (or as we used to say: yes, well, no fine).

I guess that qualifies under the "any" part of "any advice," but courses
(and instructors) are not that easy to come by. :) Besides, I've already
paid and I doubt I can get a refund. after 75% of the class has been
completed.

But I assume from your advice that it is a bad suggestion he made? Even
though PHP clearly allows for using output buffering and even rearranges
the output to put the headers first in the output buffer?
Re: buffering to allow headers in code? [message #170167 is a reply to message #170163] Thu, 14 October 2010 15:08 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 14/10/10 14:39, MikeB wrote:

> What to do?

Make any decisions about whether you need to send control headers before
you start trying to output any html.

What data is not available when you assemble the navbar that you wish to
show in your navbar, and why is it not available?

This sounds like you have a sequencing issue, and may need to switch
round the order in which you are trying to do things. It should be
possible to assemble all the information needed to generate the webpage
before outputting any html.

Rgds

Denis McMahon
Re: buffering to allow headers in code? [message #170168 is a reply to message #170166] Thu, 14 October 2010 15:16 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(MikeB)

> Jerry Stuckle wrote:
>> On 10/14/2010 9:39 AM, MikeB wrote:
>>>
>>> Thanks for any advice.
>>
>> Get a new instructor.
>
> Wow, (or as we used to say: yes, well, no fine).

At least partly I have to agree. If this is what your instructor told
you:

header("Location: index.php");

then he might be the wrong one for this job. The above violates the HTTP
RFC and can be considered a bug. It also violates conventions for good
URLs, because you should never link or redirect to index.* files.
Instead you use the directory - that's what these index files are for.

But for your problem - you should restructure your code. Put the login
routines first, then all the stuff that depends on it.

> But I assume from your advice that it is a bad suggestion he made?

Yes.

> Even
> though PHP clearly allows for using output buffering and even rearranges
> the output to put the headers first in the output buffer?

OB has its uses, but not for fixing problems caused by an improper code
structure.

See it this way: Before your header() call, your code already has done a
lot of things, even built a navigation bar. And for what? For nothing.
Completely useless work. If you restructure your code, you don't need
this redirect anymore.

In short: Keep the business logic before any presentation logic.

Micha
Re: buffering to allow headers in code? [message #170169 is a reply to message #170167] Thu, 14 October 2010 16:32 Go to previous messageGo to next message
MikeB is currently offline  MikeB
Messages: 65
Registered: September 2010
Karma: 0
Member
Denis McMahon wrote:
> On 14/10/10 14:39, MikeB wrote:
>
>> What to do?
>
> Make any decisions about whether you need to send control headers before
> you start trying to output any html.
>
> What data is not available when you assemble the navbar that you wish to
> show in your navbar, and why is it not available?
>
> This sounds like you have a sequencing issue, and may need to switch
> round the order in which you are trying to do things. It should be
> possible to assemble all the information needed to generate the webpage
> before outputting any html.
>

This is an introductory PHP course.

We are creating a "dynamic" web page without AJAX (JavaScript) since
that will be in the intermediate course.

The site is a single file - index.php. Structured with a table (to avoid
learning CSS at the same time as PHP and SQL) for the header, footer and
three panes in between. The left-most pane is hte navigation, the center
is the Main and the right is the "news".

Each table cell has an include() for another file that makes up the
content of that cell. eg. include("nav.inc.php") for the navigation bar.

The main cell then has some conditional php code to decide on what
include to run, eg, one for "show summary of all recipes", or "show
details for a recipe", or "enter a new recipe/comment", etc. Also, of
course for registering and logging in.

Since I'm trying to display the name of the logged in user on the left
pane, that code is included before I run the code in the "main" cell,
hence my timing problem

THe class example sidesteps it by simply not putting the data in there.

Maybe I should just go back to the class example. Would be a lot less
headache.
Re: buffering to allow headers in code? [message #170170 is a reply to message #170168] Thu, 14 October 2010 16:36 Go to previous messageGo to next message
MikeB is currently offline  MikeB
Messages: 65
Registered: September 2010
Karma: 0
Member
Michael Fesser wrote:
>
> At least partly I have to agree. If this is what your instructor told
> you:
>
> header("Location: index.php");
>
> then he might be the wrong one for this job. The above violates the HTTP
> RFC and can be considered a bug. It also violates conventions for good
> URLs, because you should never link or redirect to index.* files.
> Instead you use the directory - that's what these index files are for.

Do you mind explaining this? If I understand you, if my site is

http://localhost/recipes/index.php

I should code:

header("location: /") ?

or

header("location: localhost/recipes/") ?
Re: buffering to allow headers in code? [message #170171 is a reply to message #170169] Thu, 14 October 2010 17:15 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/14/2010 12:32 PM, MikeB wrote:
> Denis McMahon wrote:
>> On 14/10/10 14:39, MikeB wrote:
>>
>>> What to do?
>>
>> Make any decisions about whether you need to send control headers before
>> you start trying to output any html.
>>
>> What data is not available when you assemble the navbar that you wish to
>> show in your navbar, and why is it not available?
>>
>> This sounds like you have a sequencing issue, and may need to switch
>> round the order in which you are trying to do things. It should be
>> possible to assemble all the information needed to generate the webpage
>> before outputting any html.
>>
>
> This is an introductory PHP course.
>
> We are creating a "dynamic" web page without AJAX (JavaScript) since
> that will be in the intermediate course.
>
> The site is a single file - index.php. Structured with a table (to avoid
> learning CSS at the same time as PHP and SQL) for the header, footer and
> three panes in between. The left-most pane is hte navigation, the center
> is the Main and the right is the "news".
>
> Each table cell has an include() for another file that makes up the
> content of that cell. eg. include("nav.inc.php") for the navigation bar.
>
> The main cell then has some conditional php code to decide on what
> include to run, eg, one for "show summary of all recipes", or "show
> details for a recipe", or "enter a new recipe/comment", etc. Also, of
> course for registering and logging in.
>
> Since I'm trying to display the name of the logged in user on the left
> pane, that code is included before I run the code in the "main" cell,
> hence my timing problem
>
> THe class example sidesteps it by simply not putting the data in there.
>
> Maybe I should just go back to the class example. Would be a lot less
> headache.

It doesn't make a lot of difference when you *process the data* - it's
when you *display the results* that counts. It would be quite easy to
do the processing before anything is sent to the browser, then display
the results in the appropriate place.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: buffering to allow headers in code? [message #170172 is a reply to message #170170] Thu, 14 October 2010 20:48 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(MikeB)

> Michael Fesser wrote:
>>
>> At least partly I have to agree. If this is what your instructor told
>> you:
>>
>> header("Location: index.php");
>>
>> then he might be the wrong one for this job. The above violates the HTTP
>> RFC and can be considered a bug. It also violates conventions for good
>> URLs, because you should never link or redirect to index.* files.
>> Instead you use the directory - that's what these index files are for.
>
> Do you mind explaining this? If I understand you, if my site is
>
> http://localhost/recipes/index.php

The index.php should never appear in any links or redirection URLs. The
better and recommended URL for the above would be

http://localhost/recipes/

> I should code:
>
> header("location: /") ?
>
> or
>
> header("location: localhost/recipes/") ?

Almost. But this still violates the HTTP spec, which _requires_ an
absolute URL for the Location header. So this would be correct:

header('Location: http://localhost/recipes/');

Of course this will be bound to your own local machine, which is not
good. To make it more flexible, replace the 'localhost' part with
$_SERVER['HTTP_HOST']. There are even more examples in the PHP manual.
Just see the page for the header() function for more details.

Micha
Re: buffering to allow headers in code? [message #170173 is a reply to message #170169] Thu, 14 October 2010 20:51 Go to previous messageGo to next message
Hamish Campbell is currently offline  Hamish Campbell
Messages: 15
Registered: September 2010
Karma: 0
Junior Member
On Oct 15, 5:32 am, MikeB <mpbr...@gmail.com> wrote:
> Since I'm trying to display the name of the logged in user on the left
> pane, that code is included before I run the code in the "main" cell,
> hence my timing problem

This is what was meant by "restructuring your code". You should really
perform any state operations (like 'login user x', 'delete page y',
etc) before you start building any output. Obviously, since you're
just starting out, it's not helpful to talk about MVC patterns (worth
a Google and some questions to your instructor, just to get your
money's worth :P), but try to think of the actual output as the final
step in the process. I.e., PHP gets the request, does all the
checking, redirection, database stuff, etc - before a single line of
output is sent to the buffer/browser.

in the meantime, sending a header redirect will work - just don't
forget to die() or exit() after the header call to stop further
(unnecessary) processing. It is a classic security blunder to assume
that code execution stops after the header is sent purely because the
browser goes on it's merry way.

Hope this helps,

Hamish
Re: buffering to allow headers in code? [message #170174 is a reply to message #170169] Thu, 14 October 2010 21:42 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 14/10/10 17:32, MikeB wrote:

> We are creating a "dynamic" web page without AJAX (JavaScript) since
> that will be in the intermediate course.
>
> The site is a single file - index.php. Structured with a table (to avoid
> learning CSS at the same time as PHP and SQL) for the header, footer and
> three panes in between. The left-most pane is hte navigation, the center
> is the Main and the right is the "news".
>
> Each table cell has an include() for another file that makes up the
> content of that cell. eg. include("nav.inc.php") for the navigation bar.
>
> The main cell then has some conditional php code to decide on what
> include to run, eg, one for "show summary of all recipes", or "show
> details for a recipe", or "enter a new recipe/comment", etc. Also, of
> course for registering and logging in.
>
> Since I'm trying to display the name of the logged in user on the left
> pane, that code is included before I run the code in the "main" cell,
> hence my timing problem
>
> THe class example sidesteps it by simply not putting the data in there.
>
> Maybe I should just go back to the class example. Would be a lot less
> headache.

The page is generated. At the point that the page is generated, you are
either logged in, or not logged in.

If you are not logged in, then presumably an option to log in is
displayed, and then presumably the whole page is reprocessed from the start.

But, this time round, you can:

(a) invoke a session handler
(b) process the log in details before you do anything else
(c) store the log in state and username in a session variable

before processing the nav menu.

Now, if you did that first, when you get down to doing nav, you can test
the logged_in session variable, and if the user is logged_in, use the
username session variable in generating your navigation bar.

Rgds

Denis McMahon
Re: buffering to allow headers in code? [message #170175 is a reply to message #170170] Sat, 16 October 2010 15:59 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
MikeB wrote:

> Michael Fesser wrote:
>> At least partly I have to agree. If this is what your instructor told
>> you:
>>
>> header("Location: index.php");
>>
>> then he might be the wrong one for this job. The above violates the HTTP
>> RFC and can be considered a bug. It also violates conventions for good
>> URLs, because you should never link or redirect to index.* files.
>> Instead you use the directory - that's what these index files are for.
>
> Do you mind explaining this? If I understand you, if my site is
>
> http://localhost/recipes/index.php
>
> I should code:
>
> header("location: /") ?
>
> or
>
> header("location: localhost/recipes/") ?

None of the above. You should not need to use the header() function at all:

<http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex>

But if you use it, you need to do it as Michael suggested, using
$_SERVER['HTTP_HOST'] in the header field value, for the host name is needed
for an (absolute) URI of the form

http://host/path/

as required by HTTP ─ <http://www.w3.org/Protocols/rfc2616/rfc2616-
sec14.html> ─ and you don't want to hard-code it.


HTH

PointedEars
--
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
Re: buffering to allow headers in code? [message #170177 is a reply to message #170175] Sat, 16 October 2010 20:26 Go to previous messageGo to next message
MikeB is currently offline  MikeB
Messages: 65
Registered: September 2010
Karma: 0
Member
Thomas 'PointedEars' Lahn wrote:
> MikeB wrote:
>
>>
>> Do you mind explaining this? If I understand you, if my site is
>>
>> http://localhost/recipes/index.php
>>
>> I should code:
>>
>> header("location: /") ?
>>
>> or
>>
>> header("location: localhost/recipes/") ?
>
> None of the above. You should not need to use the header() function at all:
>
> <http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex>

This is not at all clear to me. You refer me to an Apache page, where I
cannot programatically code stuff. More specifically, mod.dir is to
define what happens if i send in a URL without a file and extension.

How does this help me if I'm in the midle of a PHP program and I decide
I need to reload the page?
Re: buffering to allow headers in code? [message #170178 is a reply to message #170177] Sun, 17 October 2010 02:12 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/16/2010 4:26 PM, MikeB wrote:
> Thomas 'PointedEars' Lahn wrote:
>> MikeB wrote:
>>
>>>
>>> Do you mind explaining this? If I understand you, if my site is
>>>
>>> http://localhost/recipes/index.php
>>>
>>> I should code:
>>>
>>> header("location: /") ?
>>>
>>> or
>>>
>>> header("location: localhost/recipes/") ?
>>
>> None of the above. You should not need to use the header() function at
>> all:
>>
>> <http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex>
>
> This is not at all clear to me. You refer me to an Apache page, where I
> cannot programatically code stuff. More specifically, mod.dir is to
> define what happens if i send in a URL without a file and extension.
>
> How does this help me if I'm in the midle of a PHP program and I decide
> I need to reload the page?
>
>
>
>

First of all, "Pointed Ears" is a troll with no idea what he's talking
about. Just check this and other newsgroups.

header() is a perfectly good function to use where necessary. One of
the things it can do is tell the browser to redirect to a new page. But
what Micha is saying is correct - use an absolute URI when redirecting,
i.e. including the domain.

For instance, header('Location:http://www.example.com/recipes'); would
be correct. header('Location:/recipes') would not.

Sure, most browsers today would accept the latter and redirect
accordingly; however, that is not according to the RFC's and is just
something many (not necessarily all) browsers currently do. The former
will work with ALL RFC-compliant browsers.

But as you've noted, this cannot be done after *any* output (even white
space) has been sent to the browser - that is a limitation of the HTTP
protocol, not PHP. The solution is to restructure your code such that
it makes the decision as to whether to redirect (or any other header()
call) is performed before any output to the browser.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: buffering to allow headers in code? [message #170180 is a reply to message #170172] Sun, 17 October 2010 04:11 Go to previous messageGo to next message
MikeB is currently offline  MikeB
Messages: 65
Registered: September 2010
Karma: 0
Member
Michael Fesser wrote:
So this would be correct:
>
> header('Location: http://localhost/recipes/');
>
> Of course this will be bound to your own local machine, which is not
> good. To make it more flexible, replace the 'localhost' part with
> $_SERVER['HTTP_HOST']. There are even more examples in the PHP manual.
> Just see the page for the header() function for more details.
>

OK, I can see how to construct that URL (or is it s URI?) from the
variables I have. This is all fine and dandy if I want to redirect to
the root page for a website, but what if I want to redirect to something
other than the index.php (or index.html) page that sits at the top of
the website? Or are you saying that all redirect must always redirect
to the top page of a website?

I'm sorry if I'm obtuse. I'm not trying to be, I'm just unfamiliar with
what is "right."

And then I get distracted by pointy ears and spend a lot of time on
stuff that does not help. :(

MikeB
Re: buffering to allow headers in code? [message #170183 is a reply to message #170180] Sun, 17 October 2010 04:52 Go to previous messageGo to next message
Hamish Campbell is currently offline  Hamish Campbell
Messages: 15
Registered: September 2010
Karma: 0
Junior Member
On Oct 17, 5:11 pm, MikeB <mpbr...@gmail.com> wrote:
> ... This is all fine and dandy if I want to redirect to
> the root page for a website, but what if I want to redirect to something
> other than the index.php (or index.html) page that sits at the top of
> the website?  Or are you saying that all redirect must always redirect
> to the top page of a website?

A Location header should provide an absolute URI - and that can
include specific resources (e.g. http://www.example.com/page-1.html).

Michael's objection to using index.php in the URI is purely stylistic.

Not sure what Pointy Ears was going on about not needing the header
function.

So, to answer your question: no it does not have to point to the root
page - just any *absolute* URI.

Regards

Hamish
Re: buffering to allow headers in code? [message #170194 is a reply to message #170177] Sun, 17 October 2010 17:31 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
MikeB wrote:

> Thomas 'PointedEars' Lahn wrote:
>> MikeB wrote:
>>> Do you mind explaining this? If I understand you, if my site is
>>>
>>> http://localhost/recipes/index.php
>>>
>>> I should code:
>>>
>>> header("location: /") ?
>>>
>>> or
>>>
>>> header("location: localhost/recipes/") ?
>>
>> None of the above. You should not need to use the header() function at
>> all:
>>
>> <http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex>
>
> This is not at all clear to me. You refer me to an Apache page, where I
> cannot programatically code stuff.

I have referred you to the Apache documentation telling you how to define
index.php as the "directory index" so that it is not necessary to write
index.php in the URI to begin with. See also
<http://www.w3.org/QA/Tips/uri-choose>.

> More specifically, mod.dir is to define what happens if i send in a URL
> without a file and extension.

Yes. And?

> How does this help me if I'm in the midle of a PHP program and I decide
> I need to reload the page?

You appear to be a bit confused, and your use-case is not at all clear to
me. For reloading a document (there really are no "pages" on the Web) you
would choose *client-side* means, of course.


PointedEars
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f806at$ail$1$8300dec7(at)news(dot)demon(dot)co(dot)uk>
Re: buffering to allow headers in code? [message #170195 is a reply to message #170180] Sun, 17 October 2010 17:39 Go to previous messageGo to next message
Thomas 'PointedEars'  is currently offline  Thomas 'PointedEars'
Messages: 701
Registered: October 2010
Karma: 0
Senior Member
MikeB wrote:

> Michael Fesser wrote:
> So this would be correct:
>> header('Location: http://localhost/recipes/');
>>
>> Of course this will be bound to your own local machine, which is not
>> good. To make it more flexible, replace the 'localhost' part with
>> $_SERVER['HTTP_HOST']. There are even more examples in the PHP manual.
>> Just see the page for the header() function for more details.
>
> OK, I can see how to construct that URL (or is it s URI?) from the

URLs can be understood as a subset of URIs (see the RFC).

> variables I have. This is all fine and dandy if I want to redirect to
> the root page for a website, but what if I want to redirect to something
> other than the index.php (or index.html) page that sits at the top of
> the website?

RTFM. The DirectoryIndex directive value is being inherited from parent
directories (or the server configuration) and can be overwritten (if the
required privileges are provided).

BTW, none of this has anything to do with PHP besides using the header()
function.

> Or are you saying that all redirect must always redirect to the top page
> of a website?

Certainly not.

> I'm sorry if I'm obtuse. I'm not trying to be, I'm just unfamiliar with
> what is "right."
>
> And then I get distracted by pointy ears and spend a lot of time on
> stuff that does not help. :(

For someone trying to not be obtuse, you are rather quick at jumping to
conclusions and pointing fingers at people when the problem is with *you*
(either failing to explain your use-case or understanding the suggested
solutions). Please change your attitude or go away.


Score adjusted

PointedEars
--
Anyone who slaps a 'this page is best viewed with Browser X' label on
a Web page appears to be yearning for the bad old days, before the Web,
when you had very little chance of reading a document written on another
computer, another word processor, or another network. -- Tim Berners-Lee
Re: buffering to allow headers in code? [message #170199 is a reply to message #170195] Sun, 17 October 2010 21:08 Go to previous messageGo to next message
Hamish Campbell is currently offline  Hamish Campbell
Messages: 15
Registered: September 2010
Karma: 0
Junior Member
On Oct 18, 6:39 am, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
> MikeB wrote:
>> And then I get distracted by pointy ears and spend a lot of time on
>> stuff that does not help. :(
>
> For someone trying to not be obtuse, you are rather quick at jumping to
> conclusions and pointing fingers at people when the problem is with *you*
> (either failing to explain your use-case or understanding the suggested
> solutions).  Please change your attitude or go away.

Your own comment gives you away, PE:

> BTW, none of this has anything to do with PHP besides using the header()
> function.

Stop getting your jollies out of setting people up so you can knock
them back down with your Flame button (you know, below to "Function
RTFM", next to "Page RFC" on your keyboard of faux-helpfulness).

Regards

Hamish
Re: buffering to allow headers in code? [message #170202 is a reply to message #170199] Mon, 18 October 2010 00:01 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/17/2010 5:08 PM, Hamish Campbell wrote:
> On Oct 18, 6:39 am, Thomas 'PointedEars' Lahn<PointedE...@web.de>
> wrote:
>> MikeB wrote:
>>> And then I get distracted by pointy ears and spend a lot of time on
>>> stuff that does not help. :(
>>
>> For someone trying to not be obtuse, you are rather quick at jumping to
>> conclusions and pointing fingers at people when the problem is with *you*
>> (either failing to explain your use-case or understanding the suggested
>> solutions). Please change your attitude or go away.
>
> Your own comment gives you away, PE:
>
>> BTW, none of this has anything to do with PHP besides using the header()
>> function.
>
> Stop getting your jollies out of setting people up so you can knock
> them back down with your Flame button (you know, below to "Function
> RTFM", next to "Page RFC" on your keyboard of faux-helpfulness).
>
> Regards
>
> Hamish

Hamish, if you look back through this and other newsgroups, that's about
all "Pointed Ears" is good for.

Maybe a better nickname than "Pointed Ears" would be "Pin Head". It
would be much more appropriate.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: buffering to allow headers in code? [message #170203 is a reply to message #170194] Mon, 18 October 2010 00:03 Go to previous message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 10/17/2010 1:31 PM, Thomas 'PointedEars' Lahn wrote:
> MikeB wrote:
>
>> Thomas 'PointedEars' Lahn wrote:
>>> MikeB wrote:
>>>> Do you mind explaining this? If I understand you, if my site is
>>>>
>>>> http://localhost/recipes/index.php
>>>>
>>>> I should code:
>>>>
>>>> header("location: /") ?
>>>>
>>>> or
>>>>
>>>> header("location: localhost/recipes/") ?
>>>
>>> None of the above. You should not need to use the header() function at
>>> all:
>>>
>>> <http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex>
>>
>> This is not at all clear to me. You refer me to an Apache page, where I
>> cannot programatically code stuff.
>
> I have referred you to the Apache documentation telling you how to define
> index.php as the "directory index" so that it is not necessary to write
> index.php in the URI to begin with. See also
> <http://www.w3.org/QA/Tips/uri-choose>.
>
>> More specifically, mod.dir is to define what happens if i send in a URL
>> without a file and extension.
>
> Yes. And?
>
>> How does this help me if I'm in the midle of a PHP program and I decide
>> I need to reload the page?
>
> You appear to be a bit confused, and your use-case is not at all clear to
> me. For reloading a document (there really are no "pages" on the Web) you
> would choose *client-side* means, of course.
>
>
> PointedEars

And, as usual, you are a total idiot.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Mesothelioma
Next Topic: Good code or bad code?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 12 22:09:53 GMT 2024

Total time taken to generate the page: 0.02371 seconds