Re: [PHP] Any PHP equivalent of Macromedia ColdFusion's location tag?

2002-03-27 Thread webapprentice

I now recall that ColdFusion's location tag accepts no data parameters, so
you can't pass data to it.  It is essentially a redirect.  Thus, it may be
doing an HTTP header location under the hood.

In ColdFusion, I may have logic like so:
-

 

OK!




I don't get any errors, so I think it buffers the entire output first and
then throws away if it determines if it needs to go elsewhere.

In PHP, it would look something like this:



   


This will not run, because of the whitespace.  I presume PHP immediately
begins the http/html stream as soon as it sees non-php code.

In ColdFusion, it doesn't care about the whitespace.
In PHP, it does care about the whitespace.

That is what I discovered in my original problem.  I had a whitespace
between the php identifiers.  I simply closed off the whitespace, and I was
fine.

Thanks for clarifying all this.

Sincerely,
Stephen






- Original Message -
From: "Rasmus Lerdorf" <[EMAIL PROTECTED]>
To: "webapprentice" <[EMAIL PROTECTED]>
Cc: "James" <[EMAIL PROTECTED]>; "Jason Murray"
<[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, March 27, 2002 12:24 AM
Subject: Re: [PHP] Any PHP equivalent of Macromedia ColdFusion's location
tag?


> > Hi Mr. Lerdorf,
> > I look forward to you upcoming O'Reilly PHP book. =)
> >
> > Yes, a META tag refresh or Javascript control seems to be the only way
left.
> > Strange that URL redirection is so unusual to implement in PHP compared
to
> > ASP or Coldfusion (unless they do something klunky under the hood).
>
> They do. There is no magic here. If you want output on a page and also do
> a redirect, the only way to do it is with a javascript meta-refresh (well,
> you can do some tricks with frames as well, but I lump those tricks under
> Javascript redirects). I don't care what ASP of Cold Fusion tells you, if
> they allow you to send some data for the page and then redirect, then they
> are either doing a Javascript meta-refresh or simply tossing your data and
> doing a Location redirect.
>
> If you have no output, then you can use a Location redirect.  What ASP and
> Cond Fusion might do is buffer your output and simply throw it away if you
> then at some point do a Location redirect.  That seems kind of silly to me
> though.  It seems like a mistake to me to just chuck away output data like
> that.  You can do that with PHP as well by turning on output buffering.
> You can send all sorts of output after a Location redirect, but there will
> be no browser around to see it because it has already received the
> Location redirect and is off viewing the other page.
>
> > Anyway, I also noticed that when the manual says you cannot output
ANYTHING,
> > I found out that if I close out all my spaces in the PHP page by
tightening
> > the php container tags, I will not output anything first.  I forgot that
> > even whitespace would be considered a web page and would generate http
> > headers (since the PHP processor probably translates whitespace as
> > echo/print statements).
>
> Yup, a space is as valid a character as any other.
>
> -Rasmus
>
> PS. One of the things with PHP is that we have never gone out of our way
> to hide the actual mechanics of HTTP very much from the users.  I think it
> is important for people to actually understand what is going on.  That's
> why we don't have a redirect() function but instead tell you to send an
> HTTP header called Location.  Because that is what needs to happen under
> the covers.
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Any PHP equivalent of Macromedia ColdFusion's location tag?

2002-03-26 Thread Jason Murray

Or, alter your page's structure so that it writes its output into a 
buffer, and echo/print it at the end of the page. That way you can
do the redirect at any point it's needed within the page logic.

Jason

-- 
Jason Murray
[EMAIL PROTECTED]
Web Developer, Melbourne IT
"Work now, freak later!"

> -Original Message-
> From: webapprentice [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, March 27, 2002 4:25 PM
> To: Rasmus Lerdorf
> Cc: James; Jason Murray; [EMAIL PROTECTED]
> Subject: Re: [PHP] Any PHP equivalent of Macromedia ColdFusion's
> location tag?
> 
> 
> Hi Mr. Lerdorf,
> I look forward to you upcoming O'Reilly PHP book. =)
> 
> Yes, a META tag refresh or Javascript control seems to be the 
> only way left.
> Strange that URL redirection is so unusual to implement in 
> PHP compared to
> ASP or Coldfusion (unless they do something klunky under the hood).
> 
> Anyway, I also noticed that when the manual says you cannot 
> output ANYTHING,
> I found out that if I close out all my spaces in the PHP page 
> by tightening
> the php container tags, I will not output anything first.  I 
> forgot that
> even whitespace would be considered a web page and would generate http
> headers (since the PHP processor probably translates whitespace as
> echo/print statements).
> 
> Thanks.
> 
> --Stephen
> 
> - Original Message -
> From: "Rasmus Lerdorf" <[EMAIL PROTECTED]>
> To: "webapprentice" <[EMAIL PROTECTED]>
> Cc: "James" <[EMAIL PROTECTED]>; "Jason Murray"
> <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Wednesday, March 27, 2002 12:01 AM
> Subject: Re: [PHP] Any PHP equivalent of Macromedia 
> ColdFusion's location
> tag?
> 
> 
> > So use a Javascript meta-refresh
> >
> > On Wed, 27 Mar 2002, webapprentice wrote:
> >
> > > Hi,
> > > Thanks for the reply.  I saw this as well in the mailing 
> list archives,
> but
> > > everyone is saying you cannot output ANYTHING before 
> calling header.
> > >
> > > Unfortunately, I'm calling this at the end of a process, 
> so it won't
> work.
> > > It tells me I've already sent out header information.
> > >
> > > I've basically created a single PHP page with a form.  
> When the form is
> > > submitted, it submits to itself.  It checks if the form 
> is submitted,
> and
> > > then goes to mail the contents to someone.  After 
> mailing, I want to go
> to a
> > > Thank You page.  I want to get away from this PHP page, 
> because I don't
> want
> > > a person refreshing the page and causing the PHP page to 
> submit again.
> > >
> > > Thus, is there something else I can do?  Or am I just not 
> seeing this?
> > >
> > > Thanks,
> > > Stephen
> > >
> > >
> > >
> > >
> > > - Original Message -
> > > From: "James" <[EMAIL PROTECTED]>
> > > To: "webapprentice" <[EMAIL PROTECTED]>
> > > Sent: Tuesday, March 26, 2002 10:20 PM
> > > Subject: Re: [PHP] Any PHP equivalent of Macromedia ColdFusion's
> location
> > > tag?
> > >
> > >
> > > > header("Location: http://www.google.com";);
> > > > replace that url with the page you want it to go to
> > > >
> > > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Any PHP equivalent of Macromedia ColdFusion's location tag?

2002-03-26 Thread webapprentice

Hi Mr. Lerdorf,
I look forward to you upcoming O'Reilly PHP book. =)

Yes, a META tag refresh or Javascript control seems to be the only way left.
Strange that URL redirection is so unusual to implement in PHP compared to
ASP or Coldfusion (unless they do something klunky under the hood).

Anyway, I also noticed that when the manual says you cannot output ANYTHING,
I found out that if I close out all my spaces in the PHP page by tightening
the php container tags, I will not output anything first.  I forgot that
even whitespace would be considered a web page and would generate http
headers (since the PHP processor probably translates whitespace as
echo/print statements).

Thanks.

--Stephen

- Original Message -
From: "Rasmus Lerdorf" <[EMAIL PROTECTED]>
To: "webapprentice" <[EMAIL PROTECTED]>
Cc: "James" <[EMAIL PROTECTED]>; "Jason Murray"
<[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, March 27, 2002 12:01 AM
Subject: Re: [PHP] Any PHP equivalent of Macromedia ColdFusion's location
tag?


> So use a Javascript meta-refresh
>
> On Wed, 27 Mar 2002, webapprentice wrote:
>
> > Hi,
> > Thanks for the reply.  I saw this as well in the mailing list archives,
but
> > everyone is saying you cannot output ANYTHING before calling header.
> >
> > Unfortunately, I'm calling this at the end of a process, so it won't
work.
> > It tells me I've already sent out header information.
> >
> > I've basically created a single PHP page with a form.  When the form is
> > submitted, it submits to itself.  It checks if the form is submitted,
and
> > then goes to mail the contents to someone.  After mailing, I want to go
to a
> > Thank You page.  I want to get away from this PHP page, because I don't
want
> > a person refreshing the page and causing the PHP page to submit again.
> >
> > Thus, is there something else I can do?  Or am I just not seeing this?
> >
> > Thanks,
> > Stephen
> >
> >
> >
> >
> > - Original Message -
> > From: "James" <[EMAIL PROTECTED]>
> > To: "webapprentice" <[EMAIL PROTECTED]>
> > Sent: Tuesday, March 26, 2002 10:20 PM
> > Subject: Re: [PHP] Any PHP equivalent of Macromedia ColdFusion's
location
> > tag?
> >
> >
> > > header("Location: http://www.google.com";);
> > > replace that url with the page you want it to go to
> > >
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Any PHP equivalent of Macromedia ColdFusion's location tag?

2002-03-26 Thread webapprentice

Hi,
Thanks for the reply.  I saw this as well in the mailing list archives, but
everyone is saying you cannot output ANYTHING before calling header.

Unfortunately, I'm calling this at the end of a process, so it won't work.
It tells me I've already sent out header information.

I've basically created a single PHP page with a form.  When the form is
submitted, it submits to itself.  It checks if the form is submitted, and
then goes to mail the contents to someone.  After mailing, I want to go to a
Thank You page.  I want to get away from this PHP page, because I don't want
a person refreshing the page and causing the PHP page to submit again.

Thus, is there something else I can do?  Or am I just not seeing this?

Thanks,
Stephen




- Original Message -
From: "James" <[EMAIL PROTECTED]>
To: "webapprentice" <[EMAIL PROTECTED]>
Sent: Tuesday, March 26, 2002 10:20 PM
Subject: Re: [PHP] Any PHP equivalent of Macromedia ColdFusion's location
tag?


> header("Location: http://www.google.com";);
> replace that url with the page you want it to go to
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Any PHP equivalent of Macromedia ColdFusion's location tag?

2002-03-26 Thread Jason Murray

> Is there any PHP function that works like ColdFusion's location tag?
> After a certain execution, I wish to leave the current PHP 
> page entirely and go to another page.  Is this possible?

That's a HTTP Header, so you want to use the ... Header() command.

A Location header is what does the redirection.

http://url.of.site/path/to/file.html";); ?>

J

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php