Redirecting between PHP Pages | |
Two inter-related questions:
If I'm in PHP page a.php, and I want to switch control to page b.php,
the only mechanism I've come across is to use header('Location:
someURL") ;
This has two drawbacks - it seems inefficient to me - you essentially
have to "bounce" a request/response off the browser to switch between
PHP pages - leaving and returning to PHP just to switch pages, and
also it uses the GET method and, I'd assume, therefore restricts you
on the length of the URL and therefore the number of name/value pairs
you can send before they get truncated.
Q1: Is there an internal PHP server-side page redirection mechanism
that would/could provide a more efficient mechanism for switching
between PHP pages?
Q2: Alternatively, is there a POST equivalent to header("Location:")
that I could use from within PHP to redirect between pages, so that
the number of name/value pairs I could send is unlimited?
---
Rob Tweed
M/Gateway Developments Ltd
Global DOMination with eXtc : http://www.mgateway.tzo.com
--- | | | | re: Redirecting between PHP Pages
In article <0mhea0d2k2iohgkbcsd8akt5ojbgf03pau@4ax.com>, Rob Tweed wrote:[color=blue]
> Two inter-related questions:
>
> If I'm in PHP page a.php, and I want to switch control to page b.php,
> the only mechanism I've come across is to use header('Location:
> someURL") ;
>
> This has two drawbacks - it seems inefficient to me - you essentially
> have to "bounce" a request/response off the browser to switch between
> PHP pages - leaving and returning to PHP just to switch pages, and
> also it uses the GET method and, I'd assume, therefore restricts you
> on the length of the URL and therefore the number of name/value pairs
> you can send before they get truncated.[/color]
the major drawback: You also loose the variables that where in the
GET/POST request.
[color=blue]
> Q1: Is there an internal PHP server-side page redirection mechanism
> that would/could provide a more efficient mechanism for switching
> between PHP pages?
>
> Q2: Alternatively, is there a POST equivalent to header("Location:")
> that I could use from within PHP to redirect between pages, so that
> the number of name/value pairs I could send is unlimited?[/color]
What is wrong with require(_once), include(_once), readfile, eval
functions?
-- http://home.mysth.be/~timvw | | | | re: Redirecting between PHP Pages
Tim
Thanks for the reply.
See below...
On 16 May 2004 13:01:56 GMT, Tim Van Wassenhove <euki@pi.be> wrote:
[color=blue]
>In article <0mhea0d2k2iohgkbcsd8akt5ojbgf03pau@4ax.com>, Rob Tweed wrote:[color=green]
>> Two inter-related questions:
>>
>> If I'm in PHP page a.php, and I want to switch control to page b.php,
>> the only mechanism I've come across is to use header('Location:
>> someURL") ;
>>
>> This has two drawbacks - it seems inefficient to me - you essentially
>> have to "bounce" a request/response off the browser to switch between
>> PHP pages - leaving and returning to PHP just to switch pages, and
>> also it uses the GET method and, I'd assume, therefore restricts you
>> on the length of the URL and therefore the number of name/value pairs
>> you can send before they get truncated.[/color]
>
>the major drawback: You also loose the variables that where in the
>GET/POST request.[/color]
Very true,
[color=blue]
>[color=green]
>> Q1: Is there an internal PHP server-side page redirection mechanism
>> that would/could provide a more efficient mechanism for switching
>> between PHP pages?
>>
>> Q2: Alternatively, is there a POST equivalent to header("Location:")
>> that I could use from within PHP to redirect between pages, so that
>> the number of name/value pairs I could send is unlimited?[/color]
>
>What is wrong with require(_once), include(_once), readfile, eval
>functions?[/color]
Sorry but I'm not sure what you're getting at. Could you give an
example of what you mean - ie how these functions can be used to
achieve what I'm trying to do?
Many thanks
Rob
---
Rob Tweed
M/Gateway Developments Ltd
Global DOMination with eXtc : http://www.mgateway.tzo.com
--- | | | | re: Redirecting between PHP Pages
In article <dn5fa0hv2d0nq8ges341fq07fj5apvtdb1@4ax.com>, Rob Tweed wrote:[color=blue][color=green][color=darkred]
>>> If I'm in PHP page a.php, and I want to switch control to page b.php,
>>> the only mechanism I've come across is to use header('Location:
>>> someURL") ;[/color][/color][/color]
[color=blue][color=green]
>>What is wrong with require(_once), include(_once), readfile, eval
>>functions?[/color]
>
> Sorry but I'm not sure what you're getting at. Could you give an
> example of what you mean - ie how these functions can be used to
> achieve what I'm trying to do?[/color]
Well, assume you have a file index.php
If the user is authenticated, he should see a screen with his settings,
if he's not authenticated, he should see the login page.
<?php
if (isAuthenticated()) {
// lookup some stuff we would like to pass to the next page
require_once('user_settings.php');
} else {
require_once('user_login.php');
}
?>
--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php> | | | | re: Redirecting between PHP Pages
Hmmm interesting. Let me just put this in context so perhaps others
can comment and so I can get my head round this some more.
One of the most common things you need to do in a web application is
as follows :
User has page "a.php" in his browser. It contains a form and a submit
button. When the user fills out the form and hits the submit button,
the form contents must be validated at the back end - typically
against a database, but at the very least in a php script. Depending
on the outcome of the validation, you want to do one of two things :
- if the validation was OK, move the user to the next page, eg "b.php"
-if the the validation failed, put "a.php" back on the user's
browser, probably with an appropriate error message.
The validation script could run at the start of "a.php" and redirect
to "b.php" using header("Location: b.php") if there were no errors.
Alternatively the form in "a.php" could submit with an action of
"b.php" in which case the validation script would be in "b.php", with
a redirection back to "a.php" if an error occurred.
Of course a third approach would be to do the validation in a third
page "c.php" which redirects to "a.php" or "b.php" depending on
outcome.
A fourth approach would be to have all the HTML and scripts in a
single container php page, with the various bits of HTML being
rendered conditionally depending on outcome. I think your suggestion
is a variant on this theme where the chunks of HTML to be rendered
come conditionally from files that are included inside a generic
container page.
The question is, what's the best approach? The first two suffer from
the nuisance value and limitations of the redirection via the
header("Location: xxx") that we've already noted. It seems a shame
that there's no apparent way to do a PHP server-side redirect to
another page in a way that would retain the current environment -
variables, arrays etc - that seems a simpler and more intuitive
approach than the alternatives.
What's the most common practice(s) for this scenario? Any other
thoughts/ideas?
Rob
On 16 May 2004 17:01:29 GMT, Tim Van Wassenhove <euki@pi.be> wrote:
[color=blue]
>In article <dn5fa0hv2d0nq8ges341fq07fj5apvtdb1@4ax.com>, Rob Tweed wrote:[color=green][color=darkred]
>>>> If I'm in PHP page a.php, and I want to switch control to page b.php,
>>>> the only mechanism I've come across is to use header('Location:
>>>> someURL") ;[/color][/color]
>[color=green][color=darkred]
>>>What is wrong with require(_once), include(_once), readfile, eval
>>>functions?[/color]
>>
>> Sorry but I'm not sure what you're getting at. Could you give an
>> example of what you mean - ie how these functions can be used to
>> achieve what I'm trying to do?[/color]
>
>Well, assume you have a file index.php
>
>If the user is authenticated, he should see a screen with his settings,
>if he's not authenticated, he should see the login page.
>
><?php
>
>if (isAuthenticated()) {
>
> // lookup some stuff we would like to pass to the next page
>
> require_once('user_settings.php');
>
>} else {
>
> require_once('user_login.php');
>
>}
>?>[/color]
---
Rob Tweed
M/Gateway Developments Ltd
Global DOMination with eXtc : http://www.mgateway.tzo.com
--- | | | | re: Redirecting between PHP Pages
Rob Tweed <rtweed@blueyonder.co.uk> wrote in
news:u8dfa05td02fjqfbou93j1fqt1p61ta7e1@4ax.com:
[color=blue]
> What's the most common practice(s) for this scenario? Any other
> thoughts/ideas?[/color]
cgi scripts are used alot, or so it seems.
Im no expert but there is no bad point to keeping pages simple. Load the
form, go to the validation page, go to the success page... or go back to
the form page. Otherwise you will have to embed all the html in print
statements, instead of only where its needed. You could use specific
includes, but that would defeat the purpose of using a single file anyways. | | | | re: Redirecting between PHP Pages
"Rob Tweed" <rtweed@blueyonder.co.uk> wrote in message
news:0mhea0d2k2iohgkbcsd8akt5ojbgf03pau@4ax.com...[color=blue]
> This has two drawbacks - it seems inefficient to me - you essentially
> have to "bounce" a request/response off the browser to switch between
> PHP pages - leaving and returning to PHP just to switch pages, and
> also it uses the GET method and, I'd assume, therefore restricts you
> on the length of the URL and therefore the number of name/value pairs
> you can send before they get truncated.[/color]
In a typical setup, where the request is done through a persistent HTTP
connection, PHP is running as a module, and database connection is
persistent, the overhead of a redirect isn't very large. There's of course
the problem of passing variables to the other page. But then if it makes use
of so many variable from the original page, then maybe it should be part of
the same script.
[color=blue]
> Q1: Is there an internal PHP server-side page redirection mechanism
> that would/could provide a more efficient mechanism for switching
> between PHP pages?[/color]
As Tim said, there's include() or require(). It's not a practice I would
recommend though. Makes it harder to debug when you lose the 1 to 1
correlation between URL and PHP script.
[color=blue]
> Q2: Alternatively, is there a POST equivalent to header("Location:")
> that I could use from within PHP to redirect between pages, so that
> the number of name/value pairs I could send is unlimited?[/color]
Yes. If you do
header("HTTP/1.1 Temporary Redirect 307");
header("Location: /screw_rfc2616.php");
then the browser will repost to the other page. Only works correctly in IE
though. | | | | re: Redirecting between PHP Pages
In article <u8dfa05td02fjqfbou93j1fqt1p61ta7e1@4ax.com>, Rob Tweed wrote:[color=blue]
> The question is, what's the best approach? The first two suffer from
> the nuisance value and limitations of the redirection via the
> header("Location: xxx") that we've already noted. It seems a shame
> that there's no apparent way to do a PHP server-side redirect to
> another page in a way that would retain the current environment -
> variables, arrays etc - that seems a simpler and more intuitive
> approach than the alternatives.[/color]
An extension of the include/require stuff: http://www.alt-php-faq.org/local/55/#id55
--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php> | | | | re: Redirecting between PHP Pages
"Rob Tweed" <rtweed@blueyonder.co.uk> wrote in message
news:0mhea0d2k2iohgkbcsd8akt5ojbgf03pau@4ax.com...[color=blue]
> Two inter-related questions:
>
> If I'm in PHP page a.php, and I want to switch control to page b.php,
> the only mechanism I've come across is to use header('Location:
> someURL") ;
>
> This has two drawbacks - it seems inefficient to me - you essentially
> have to "bounce" a request/response off the browser to switch between
> PHP pages - leaving and returning to PHP just to switch pages, and
> also it uses the GET method and, I'd assume, therefore restricts you
> on the length of the URL and therefore the number of name/value pairs
> you can send before they get truncated.
>
> Q1: Is there an internal PHP server-side page redirection mechanism
> that would/could provide a more efficient mechanism for switching
> between PHP pages?
>[/color]
Yes and no, include() and require() is use for this kind of RESULT.
Switching between webpages ??? this is not logical as on the server-side,
the client can't see what happen with the process, so why make it
complicated like switching pages. It's just like making 2-3 additionnal
steps.
[color=blue]
> Q2: Alternatively, is there a POST equivalent to header("Location:")
> that I could use from within PHP to redirect between pages, so that
> the number of name/value pairs I could send is unlimited?
>
>[/color]
you can use fopen, fsockopen on your own server, but again, include() and
require() is the logical solution.
Maybe you should reconsider your programming method, maybe posting some code
so we can make correction, as far as I see, you have this kind of problem
because you didn't use efficiently your include() with functions and maybe
you dont understand enough the HTTP protocol.
Savut
[color=blue]
>
> ---
> Rob Tweed
> M/Gateway Developments Ltd
>
> Global DOMination with eXtc : http://www.mgateway.tzo.com
> ---[/color] | | | | re: Redirecting between PHP Pages
On Mon, 17 May 2004 11:27:28 -0400, "Savut" <webki@hotmail.com> wrote:
[color=blue]
> maybe you dont understand enough the HTTP protocol.[/color]
Do me a favour - I've been involved in web applications since 1994. I
think I understand the HTTP protocol pretty thoroughly. Thanks for
your other comments however.
---
Rob Tweed
M/Gateway Developments Ltd
Global DOMination with eXtc : http://www.mgateway.tzo.com
--- | | | | re: Redirecting between PHP Pages
"Rob Tweed" <rtweed@blueyonder.co.uk> wrote in message
news:vnqha0tp9f1t42rsn7cuueo9psh1q3enll@4ax.com...[color=blue]
> On Mon, 17 May 2004 11:27:28 -0400, "Savut" <webki@hotmail.com> wrote:
>[color=green]
> > maybe you dont understand enough the HTTP protocol.[/color]
>
> Do me a favour - I've been involved in web applications since 1994. I
> think I understand the HTTP protocol pretty thoroughly. Thanks for
> your other comments however.
>
>
> ---
> Rob Tweed
> M/Gateway Developments Ltd
>
> Global DOMination with eXtc : http://www.mgateway.tzo.com
> ---[/color]
Rob, for me that kind of answer is uncalled for, anyway, requesting help and
then using such strong replies get's you nowere.
expect to get what you provide? think about it. | | | | re: Redirecting between PHP Pages
Point taken and I apologise.
In my defence, I'd simply make the point that asking questions should
not be taken by others as an indication of ignorance of a subject.
More often than not it's actually an indication of a desire to gain
more depth in existing knowledge. The answers I received were
extremely helpful in that respect.
I shall try to bite my tongue in future :-)
On Tue, 18 May 2004 23:27:53 +0100, "RootShell" <RootShell@Netcabo.pt>
wrote:
[color=blue]
>
>"Rob Tweed" <rtweed@blueyonder.co.uk> wrote in message
>news:vnqha0tp9f1t42rsn7cuueo9psh1q3enll@4ax.com.. .[color=green]
>> On Mon, 17 May 2004 11:27:28 -0400, "Savut" <webki@hotmail.com> wrote:
>>[color=darkred]
>> > maybe you dont understand enough the HTTP protocol.[/color]
>>
>> Do me a favour - I've been involved in web applications since 1994. I
>> think I understand the HTTP protocol pretty thoroughly. Thanks for
>> your other comments however.
>>
>>
>> ---
>> Rob Tweed
>> M/Gateway Developments Ltd
>>
>> Global DOMination with eXtc : http://www.mgateway.tzo.com
>> ---[/color]
>
>Rob, for me that kind of answer is uncalled for, anyway, requesting help and
>then using such strong replies get's you nowere.
>
>expect to get what you provide? think about it.
>
>[/color]
---
Rob Tweed
M/Gateway Developments Ltd
Global DOMination with eXtc : http://www.mgateway.tzo.com
--- | | | | re: Redirecting between PHP Pages
Rob Tweed wrote:
[color=blue]
> Hmmm interesting. Let me just put this in context so perhaps others
> can comment and so I can get my head round this some more.
>
> One of the most common things you need to do in a web application is
> as follows :
>
> User has page "a.php" in his browser. It contains a form and a submit
> button. When the user fills out the form and hits the submit button,
> the form contents must be validated at the back end - typically
> against a database, but at the very least in a php script. Depending
> on the outcome of the validation, you want to do one of two things :
>
> - if the validation was OK, move the user to the next page, eg "b.php"
>
> -if the the validation failed, put "a.php" back on the user's
> browser, probably with an appropriate error message.
>
> The validation script could run at the start of "a.php" and redirect
> to "b.php" using header("Location: b.php") if there were no errors.
>
> Alternatively the form in "a.php" could submit with an action of
> "b.php" in which case the validation script would be in "b.php", with
> a redirection back to "a.php" if an error occurred.
>
> Of course a third approach would be to do the validation in a third
> page "c.php" which redirects to "a.php" or "b.php" depending on
> outcome.
>
> A fourth approach would be to have all the HTML and scripts in a
> single container php page, with the various bits of HTML being
> rendered conditionally depending on outcome. I think your suggestion
> is a variant on this theme where the chunks of HTML to be rendered
> come conditionally from files that are included inside a generic
> container page.
>
> The question is, what's the best approach? The first two suffer from
> the nuisance value and limitations of the redirection via the
> header("Location: xxx") that we've already noted. It seems a shame
> that there's no apparent way to do a PHP server-side redirect to
> another page in a way that would retain the current environment -
> variables, arrays etc - that seems a simpler and more intuitive
> approach than the alternatives.
>
> What's the most common practice(s) for this scenario? Any other
> thoughts/ideas?
>
> Rob
>
>
> On 16 May 2004 17:01:29 GMT, Tim Van Wassenhove <euki@pi.be> wrote:
>
>[color=green]
>>In article <dn5fa0hv2d0nq8ges341fq07fj5apvtdb1@4ax.com>, Rob Tweed wrote:
>>[color=darkred]
>>>>>If I'm in PHP page a.php, and I want to switch control to page b.php,
>>>>>the only mechanism I've come across is to use header('Location:
>>>>>someURL") ;[/color]
>>[color=darkred]
>>>>What is wrong with require(_once), include(_once), readfile, eval
>>>>functions?
>>>
>>>Sorry but I'm not sure what you're getting at. Could you give an
>>>example of what you mean - ie how these functions can be used to
>>>achieve what I'm trying to do?[/color]
>>
>>Well, assume you have a file index.php
>>
>>If the user is authenticated, he should see a screen with his settings,
>>if he's not authenticated, he should see the login page.
>>
>><?php
>>
>>if (isAuthenticated()) {
>>
>> // lookup some stuff we would like to pass to the next page
>>
>> require_once('user_settings.php');
>>
>>} else {
>>
>> require_once('user_login.php');
>>
>>}
>>?>[/color]
>
>
> ---
> Rob Tweed
> M/Gateway Developments Ltd
>
> Global DOMination with eXtc : http://www.mgateway.tzo.com
> ---[/color]
Rob you can do all of this in one page say index.php, you are mistaking
displaying output with requiring multiple files
if ($_POST['postform'] == "login")
{
..... Validate the user details however u like
}
if ($uservalidated == true)
{
..... Display page here
}
else
{
..... Display login form
}
Now in your html you display for the login form
<form action="index.php" method="post">
<input type="hidden" name="postform" value="login"/>
.......... rest of form
Most sites only run off of their index.php and just call functions from
other php files, you should never need a redirect your page except to
reload index.php before any output for some reason, you can dump any
varibles u need to carry over in a rediect into your session, try
running your index.php like the void main() of a c app you will find
life becomes much easier. | | | | re: Redirecting between PHP Pages
In article <c8fpok$61s$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:[color=blue]
><form action="index.php" method="post">[/color]
I prefer to use action="<?= $_SERVER['PHP_SELF'] ?>".
--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php> | | | | re: Redirecting between PHP Pages
Tim Van Wassenhove wrote:[color=blue]
> In article <c8fpok$61s$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
>[color=green]
>><form action="index.php" method="post">[/color]
>
>
> I prefer to use action="<?= $_SERVER['PHP_SELF'] ?>".
>[/color]
Thats even better yeah, but I use smarty template for my html and then
i'd have to pass an extra varible to smarty :/ | | | | re: Redirecting between PHP Pages
Very interesting and very helpful, thank you - I can see how this
approach answers my original questions.
A follow-up question: In a very large web application you may have
hundreds of "pages" and so the conditional logic that determines at
run-time which ones get displayed within the container index.php at
any specific time could get pretty complex, particularly if you had
multiple forms and/or multiple submit buttons that cause different
actions and transitions to different "pages".
Doesn't this begin to become difficult to manage with this approach?
What techniques do people tend to use to keep the mechanics both
manageable and maintainable? Do people tend to use database-driven
decision-tree logic for this, or does it tend to be coded into each
"page" - I can envisage either approach working.
PHP is now my prefered platform for web development by the way - its
power and flexibility never fails to impress me, and there's always a
new trick or technique lurking in there to make life easier - I love
it!
On Wed, 19 May 2004 16:08:22 +0200, Justin Wyer <justin@isogo.co.za>
wrote:
[color=blue]
>Rob you can do all of this in one page say index.php, you are mistaking
>displaying output with requiring multiple files
>
>if ($_POST['postform'] == "login")
>{
> ..... Validate the user details however u like
>}
>
>if ($uservalidated == true)
>{
> ..... Display page here
>}
>else
>{
> ..... Display login form
>}
>
>Now in your html you display for the login form
>
><form action="index.php" method="post">
><input type="hidden" name="postform" value="login"/>
>......... rest of form
>
>Most sites only run off of their index.php and just call functions from
>other php files, you should never need a redirect your page except to
>reload index.php before any output for some reason, you can dump any
>varibles u need to carry over in a rediect into your session, try
>running your index.php like the void main() of a c app you will find
>life becomes much easier.[/color]
---
Rob Tweed
M/Gateway Developments Ltd
Global DOMination with eXtc : http://www.mgateway.tzo.com
--- | | | | re: Redirecting between PHP Pages
In article <c8hmk0$1lf$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:[color=blue]
> Tim Van Wassenhove wrote:[color=green]
>> In article <c8fpok$61s$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
>>[color=darkred]
>>><form action="index.php" method="post">[/color]
>>
>>
>> I prefer to use action="<?= $_SERVER['PHP_SELF'] ?>".
>>[/color]
> Thats even better yeah, but I use smarty template for my html and then
> i'd have to pass an extra varible to smarty :/[/color]
I thought you could include php code directly into smarty templates.
Personally i don't like template engines that limit the user, but i can
understand that others think different about that.
--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php> | | | | re: Redirecting between PHP Pages
Rob Tweed wrote:[color=blue]
> Very interesting and very helpful, thank you - I can see how this
> approach answers my original questions.
>
> A follow-up question: In a very large web application you may have
> hundreds of "pages" and so the conditional logic that determines at
> run-time which ones get displayed within the container index.php at
> any specific time could get pretty complex, particularly if you had
> multiple forms and/or multiple submit buttons that cause different
> actions and transitions to different "pages".
>
> Doesn't this begin to become difficult to manage with this approach?
>
> What techniques do people tend to use to keep the mechanics both
> manageable and maintainable? Do people tend to use database-driven
> decision-tree logic for this, or does it tend to be coded into each
> "page" - I can envisage either approach working.
>
>
> PHP is now my prefered platform for web development by the way - its
> power and flexibility never fails to impress me, and there's always a
> new trick or technique lurking in there to make life easier - I love
> it!
>
>
>
> On Wed, 19 May 2004 16:08:22 +0200, Justin Wyer <justin@isogo.co.za>
> wrote:
>
>
>[color=green]
>>Rob you can do all of this in one page say index.php, you are mistaking
>>displaying output with requiring multiple files
>>
>>if ($_POST['postform'] == "login")
>>{
>> ..... Validate the user details however u like
>>}
>>
>>if ($uservalidated == true)
>>{
>> ..... Display page here
>>}
>>else
>>{
>> ..... Display login form
>>}
>>
>>Now in your html you display for the login form
>>
>><form action="index.php" method="post">
>><input type="hidden" name="postform" value="login"/>
>>......... rest of form
>>
>>Most sites only run off of their index.php and just call functions from
>>other php files, you should never need a redirect your page except to
>>reload index.php before any output for some reason, you can dump any
>>varibles u need to carry over in a rediect into your session, try
>>running your index.php like the void main() of a c app you will find
>>life becomes much easier.[/color]
>
>
> ---
> Rob Tweed
> M/Gateway Developments Ltd
>
> Global DOMination with eXtc : http://www.mgateway.tzo.com
> ---[/color]
That is the main reason I use a template engine so I can seperate my
design from my implementation, smarty really helps with this, I normally
run an index.php and a few other php files I have written which I use
like modules, my sessions.php, db.php and stats.php along with a
functions.php which I dump any functions I write for that specific site
in. Then I will normally store the actual page data in a database in say
a blog or news style site, then I just grab that from the database and
pass it on to smarty which then displays it as html for me.
My code style is to seperate things as much as possible, thats why I use
smarty, and if you see how I do html, I dump all my html effects into
a css file to unclutter my html as much as possible aswell. I guess it
all comes down to whats easiest for you.
I fully agree with you in that php is an awesome web development tool.
It is infact the best solution for the web, and I to always seem to be
able to find a solution to any problem I encounter, and the php manual
is the best reference any programming language has ever had.
I can truly say "Viva PHP!" | | | | re: Redirecting between PHP Pages
Tim Van Wassenhove wrote:
[color=blue]
> In article <c8hmk0$1lf$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
>[color=green]
>>Tim Van Wassenhove wrote:
>>[color=darkred]
>>>In article <c8fpok$61s$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
>>>
>>>
>>>><form action="index.php" method="post">
>>>
>>>
>>>I prefer to use action="<?= $_SERVER['PHP_SELF'] ?>".
>>>[/color]
>>
>>Thats even better yeah, but I use smarty template for my html and then
>>i'd have to pass an extra varible to smarty :/[/color]
>
>
> I thought you could include php code directly into smarty templates.
> Personally i don't like template engines that limit the user, but i can
> understand that others think different about that.
>[/color]
Yeah its all about personal preference and doing whats easiest for you. | | | | re: Redirecting between PHP Pages
In article <utloa0p355v5h50e3denmhfhk88l2c8oja@4ax.com>, Rob Tweed wrote:[color=blue]
> A follow-up question: In a very large web application you may have
> hundreds of "pages" and so the conditional logic that determines at
> run-time which ones get displayed within the container index.php at
> any specific time could get pretty complex, particularly if you had
> multiple forms and/or multiple submit buttons that cause different
> actions and transitions to different "pages".
>
> Doesn't this begin to become difficult to manage with this approach?[/color]
I think it's quite silly to pass *all* page requests through an index.php
file and apache is much better in mapping requests to specific pages.
--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php> | | | | re: Redirecting between PHP Pages
"Tim Van Wassenhove" <euki@pi.be> wrote in message
news:2h393cF8i2tiU1@uni-berlin.de...[color=blue]
> In article <utloa0p355v5h50e3denmhfhk88l2c8oja@4ax.com>, Rob Tweed wrote:[color=green]
> > A follow-up question: In a very large web application you may have
> > hundreds of "pages" and so the conditional logic that determines at
> > run-time which ones get displayed within the container index.php at
> > any specific time could get pretty complex, particularly if you had
> > multiple forms and/or multiple submit buttons that cause different
> > actions and transitions to different "pages".
> >
> > Doesn't this begin to become difficult to manage with this approach?[/color]
>
> I think it's quite silly to pass *all* page requests through an index.php
> file and apache is much better in mapping requests to specific pages.[/color]
I agree entirely. I have over 350 components in my web application, and each
of those has its own self-contained script. Control is passed from one
script to another by means of the header() function. The thought of having
everything going through a single index.php page which has to have knowledge
of every component gives me the heebie-jeebies.
--
Tony Marston http://www.tonymarston.net | | | | re: Redirecting between PHP Pages
"Tim Van Wassenhove" <euki@pi.be> wrote in message
news:2h35hkF8bsmrU1@uni-berlin.de...[color=blue]
> In article <c8hmk0$1lf$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:[color=green]
> > Tim Van Wassenhove wrote:[color=darkred]
> >> In article <c8fpok$61s$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
> >>
> >>><form action="index.php" method="post">
> >>
> >>
> >> I prefer to use action="<?= $_SERVER['PHP_SELF'] ?>".
> >>[/color]
> > Thats even better yeah, but I use smarty template for my html and then
> > i'd have to pass an extra varible to smarty :/[/color]
>
> I thought you could include php code directly into smarty templates.
> Personally i don't like template engines that limit the user, but i can
> understand that others think different about that.[/color]
Personally I have had great success with XSL stylesheets as my templating
engine. In my web application of 350+ components I have over 200 of them
using the same XSL stylesheet. How's that for reusability!
Take a look at http://www.tonymarston.co.uk/xml-xsl/reusable-xsl.html for
details.
--
Tony Marston http://www.tonymarston.net | | | | re: Redirecting between PHP Pages
Tony Marston wrote:
[color=blue]
> "Tim Van Wassenhove" <euki@pi.be> wrote in message
> news:2h393cF8i2tiU1@uni-berlin.de...
>[color=green]
>>In article <utloa0p355v5h50e3denmhfhk88l2c8oja@4ax.com>, Rob Tweed wrote:
>>[color=darkred]
>>>A follow-up question: In a very large web application you may have
>>>hundreds of "pages" and so the conditional logic that determines at
>>>run-time which ones get displayed within the container index.php at
>>>any specific time could get pretty complex, particularly if you had
>>>multiple forms and/or multiple submit buttons that cause different
>>>actions and transitions to different "pages".
>>>
>>>Doesn't this begin to become difficult to manage with this approach?[/color]
>>
>>I think it's quite silly to pass *all* page requests through an index.php
>>file and apache is much better in mapping requests to specific pages.[/color]
>
>
> I agree entirely. I have over 350 components in my web application, and each
> of those has its own self-contained script. Control is passed from one
> script to another by means of the header() function. The thought of having
> everything going through a single index.php page which has to have knowledge
> of every component gives me the heebie-jeebies.
>[/color]
Like I been saying do it the way it works best for you, if boucing
around between scripts works for u then, its best for you. I just don't
see a need in my case, most of my data get pulled from databases and
then bombed out as html to the user, I have seperate files containing
functions I use yes, but all my html in smarty templates, so I grab the
data, pass the data to smarty and then render it, so its easier for me
to have one single script controlling the grabbing and passing on than
having 50 files all doing similar things. In the end all that matters is
that your stuff works, and that its easy for you to maintain. | | | | re: Redirecting between PHP Pages
Tony Marston wrote:
[color=blue]
> "Tim Van Wassenhove" <euki@pi.be> wrote in message
> news:2h35hkF8bsmrU1@uni-berlin.de...
>[color=green]
>>In article <c8hmk0$1lf$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
>>[color=darkred]
>>>Tim Van Wassenhove wrote:
>>>
>>>>In article <c8fpok$61s$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
>>>>
>>>>
>>>>><form action="index.php" method="post">
>>>>
>>>>
>>>>I prefer to use action="<?= $_SERVER['PHP_SELF'] ?>".
>>>>
>>>
>>>Thats even better yeah, but I use smarty template for my html and then
>>>i'd have to pass an extra varible to smarty :/[/color]
>>
>>I thought you could include php code directly into smarty templates.
>>Personally i don't like template engines that limit the user, but i can
>>understand that others think different about that.[/color]
>
>
> Personally I have had great success with XSL stylesheets as my templating
> engine. In my web application of 350+ components I have over 200 of them
> using the same XSL stylesheet. How's that for reusability!
>
> Take a look at http://www.tonymarston.co.uk/xml-xsl/reusable-xsl.html for
> details.
>[/color]
Quite impressive Tony, smarty just works easier for me, I don't normally
invent wheels I use readily avalible ones to build cars. | | | | re: Redirecting between PHP Pages
"Justin Wyer" <justin@isogo.co.za> wrote in message
news:c8hvgp$leu$1@ctb-nnrp2.saix.net...[color=blue]
> Tony Marston wrote:
>[color=green]
> > "Tim Van Wassenhove" <euki@pi.be> wrote in message
> > news:2h35hkF8bsmrU1@uni-berlin.de...
> >[color=darkred]
> >>In article <c8hmk0$1lf$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
> >>
> >>>Tim Van Wassenhove wrote:
> >>>
> >>>>In article <c8fpok$61s$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
> >>>>
> >>>>
> >>>>><form action="index.php" method="post">
> >>>>
> >>>>
> >>>>I prefer to use action="<?= $_SERVER['PHP_SELF'] ?>".
> >>>>
> >>>
> >>>Thats even better yeah, but I use smarty template for my html and then
> >>>i'd have to pass an extra varible to smarty :/
> >>
> >>I thought you could include php code directly into smarty templates.
> >>Personally i don't like template engines that limit the user, but i can
> >>understand that others think different about that.[/color]
> >
> >
> > Personally I have had great success with XSL stylesheets as my[/color][/color]
templating[color=blue][color=green]
> > engine. In my web application of 350+ components I have over 200 of them
> > using the same XSL stylesheet. How's that for reusability!
> >
> > Take a look at http://www.tonymarston.co.uk/xml-xsl/reusable-xsl.html[/color][/color]
for[color=blue][color=green]
> > details.
> >[/color]
> Quite impressive Tony, smarty just works easier for me, I don't normally
> invent wheels I use readily avalible ones to build cars.[/color]
The reasons that I chose XSL as my templating engine instead of Smarty (or
any of its look-alikes) were:
(a) XSL is controlled by the World Wide Web Consortium (W3C) therefore is
open source written to a recognised standard.
(b) XML/XSL can be used with any language and is not tied to PHP.
(c) I was already familiar with XML/XSL therefore did not want to go through
the learning curve with another templating engine.
I did not *reinvent* the wheel by using XSL instead of Smarty as the XSL
engine already existed and was accessible through PHP. All I did was create
a set of stylesheets/templates for each page, just as you would have to do
with any templating engine. The real skill comes when attempting to create
flexible and reusable stylesheets that can cope with a number of different
circumstances. Do you have a single Smarty template that can deal with 200
different screen layouts?
--
Tony Marston http://www.tonymarston.net | | | | re: Redirecting between PHP Pages
Tony Marston wrote:
[color=blue]
> "Justin Wyer" <justin@isogo.co.za> wrote in message
> news:c8hvgp$leu$1@ctb-nnrp2.saix.net...
>[color=green]
>>Tony Marston wrote:
>>
>>[color=darkred]
>>>"Tim Van Wassenhove" <euki@pi.be> wrote in message
>>>news:2h35hkF8bsmrU1@uni-berlin.de...
>>>
>>>
>>>>In article <c8hmk0$1lf$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
>>>>
>>>>
>>>>>Tim Van Wassenhove wrote:
>>>>>
>>>>>
>>>>>>In article <c8fpok$61s$1@ctb-nnrp2.saix.net>, Justin Wyer wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>><form action="index.php" method="post">
>>>>>>
>>>>>>
>>>>>>I prefer to use action="<?= $_SERVER['PHP_SELF'] ?>".
>>>>>>
>>>>>
>>>>>Thats even better yeah, but I use smarty template for my html and then
>>>>>i'd have to pass an extra varible to smarty :/
>>>>
>>>>I thought you could include php code directly into smarty templates.
>>>>Personally i don't like template engines that limit the user, but i can
>>>>understand that others think different about that.
>>>
>>>
>>>Personally I have had great success with XSL stylesheets as my[/color][/color]
>
> templating
>[color=green][color=darkred]
>>>engine. In my web application of 350+ components I have over 200 of them
>>>using the same XSL stylesheet. How's that for reusability!
>>>
>>>Take a look at http://www.tonymarston.co.uk/xml-xsl/reusable-xsl.html[/color][/color]
>
> for
>[color=green][color=darkred]
>>>details.
>>>[/color]
>>
>>Quite impressive Tony, smarty just works easier for me, I don't normally
>>invent wheels I use readily avalible ones to build cars.[/color]
>
>
> The reasons that I chose XSL as my templating engine instead of Smarty (or
> any of its look-alikes) were:
> (a) XSL is controlled by the World Wide Web Consortium (W3C) therefore is
> open source written to a recognised standard.
> (b) XML/XSL can be used with any language and is not tied to PHP.
> (c) I was already familiar with XML/XSL therefore did not want to go through
> the learning curve with another templating engine.
>
> I did not *reinvent* the wheel by using XSL instead of Smarty as the XSL
> engine already existed and was accessible through PHP. All I did was create
> a set of stylesheets/templates for each page, just as you would have to do
> with any templating engine. The real skill comes when attempting to create
> flexible and reusable stylesheets that can cope with a number of different
> circumstances. Do you have a single Smarty template that can deal with 200
> different screen layouts?
>[/color]
Not really I don't have 200 pages of stuff been displayed similarily,
and I use css for stylesheeting, I just dump data to smarty and use
smarty to keep html out of my scripts, i use very little html, basicly a
few div tags, and tables only if i have to heh, otherwise I use css for
layout. And I do have very reusable css ;p
BTW some interesting articles on your site, some good reading there. |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 226,449 network members.
|