473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

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
---
Jul 17 '05 #1
25 2641
In article <0m********************************@4ax.com>, Rob Tweed wrote:
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.
the major drawback: You also loose the variables that where in the
GET/POST request.
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?


What is wrong with require(_once), include(_once), readfile, eval
functions?
--
http://home.mysth.be/~timvw
Jul 17 '05 #2
Tim

Thanks for the reply.

See below...

On 16 May 2004 13:01:56 GMT, Tim Van Wassenhove <eu**@pi.be> wrote:
In article <0m********************************@4ax.com>, Rob Tweed wrote:
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.
the major drawback: You also loose the variables that where in the
GET/POST request.


Very true,
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?


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?

Many thanks

Rob

---
Rob Tweed
M/Gateway Developments Ltd

Global DOMination with eXtc : http://www.mgateway.tzo.com
---
Jul 17 '05 #3
In article <dn********************************@4ax.com>, Rob Tweed wrote:
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") ;
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?


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>
Jul 17 '05 #4
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 <eu**@pi.be> wrote:
In article <dn********************************@4ax.com>, Rob Tweed wrote:
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") ;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?


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');

}
?>


---
Rob Tweed
M/Gateway Developments Ltd

Global DOMination with eXtc : http://www.mgateway.tzo.com
---
Jul 17 '05 #5
Rob Tweed <rt****@blueyonder.co.uk> wrote in
news:u8********************************@4ax.com:
What's the most common practice(s) for this scenario? Any other
thoughts/ideas?


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.
Jul 17 '05 #6
"Rob Tweed" <rt****@blueyonder.co.uk> wrote in message
news:0m********************************@4ax.com...
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.
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.
Q1: Is there an internal PHP server-side page redirection mechanism
that would/could provide a more efficient mechanism for switching
between PHP pages?
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.
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?


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.
Jul 17 '05 #7
In article <u8********************************@4ax.com>, Rob Tweed wrote:
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.


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>
Jul 17 '05 #8

"Rob Tweed" <rt****@blueyonder.co.uk> wrote in message
news:0m********************************@4ax.com...
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?

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


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

---
Rob Tweed
M/Gateway Developments Ltd

Global DOMination with eXtc : http://www.mgateway.tzo.com
---


Jul 17 '05 #9
On Mon, 17 May 2004 11:27:28 -0400, "Savut" <we***@hotmail.com> wrote:
maybe you dont understand enough the HTTP protocol.


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
---
Jul 17 '05 #10

"Rob Tweed" <rt****@blueyonder.co.uk> wrote in message
news:vn********************************@4ax.com...
On Mon, 17 May 2004 11:27:28 -0400, "Savut" <we***@hotmail.com> wrote:
maybe you dont understand enough the HTTP protocol.


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


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.

Jul 17 '05 #11
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" <Ro*******@Netcabo.pt>
wrote:

"Rob Tweed" <rt****@blueyonder.co.uk> wrote in message
news:vn********************************@4ax.com.. .
On Mon, 17 May 2004 11:27:28 -0400, "Savut" <we***@hotmail.com> wrote:
> maybe you dont understand enough the HTTP protocol.


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


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.


---
Rob Tweed
M/Gateway Developments Ltd

Global DOMination with eXtc : http://www.mgateway.tzo.com
---
Jul 17 '05 #12
Rob Tweed wrote:
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 <eu**@pi.be> wrote:

In article <dn********************************@4ax.com>, Rob Tweed wrote:
>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") ;

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?


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');

}
?>

---
Rob Tweed
M/Gateway Developments Ltd

Global DOMination with eXtc : http://www.mgateway.tzo.com
---


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.
Jul 17 '05 #13
In article <c8**********@ctb-nnrp2.saix.net>, Justin Wyer wrote:
<form action="index.php" method="post">


I prefer to use action="<?= $_SERVER['PHP_SELF'] ?>".

--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php>
Jul 17 '05 #14
Tim Van Wassenhove wrote:
In article <c8**********@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 :/
Jul 17 '05 #15
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 <ju****@isogo.co.za>
wrote:

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.


---
Rob Tweed
M/Gateway Developments Ltd

Global DOMination with eXtc : http://www.mgateway.tzo.com
---
Jul 17 '05 #16
In article <c8**********@ctb-nnrp2.saix.net>, Justin Wyer wrote:
Tim Van Wassenhove wrote:
In article <c8**********@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.

--
Tim Van Wassenhove <http://home.mysth.be/~timvw/contact.php>
Jul 17 '05 #17
Rob Tweed wrote:
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 <ju****@isogo.co.za>
wrote:
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.

---
Rob Tweed
M/Gateway Developments Ltd

Global DOMination with eXtc : http://www.mgateway.tzo.com
---


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!"
Jul 17 '05 #18
Tim Van Wassenhove wrote:
In article <c8**********@ctb-nnrp2.saix.net>, Justin Wyer wrote:
Tim Van Wassenhove wrote:
In article <c8**********@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.

Yeah its all about personal preference and doing whats easiest for you.
Jul 17 '05 #19
In article <ut********************************@4ax.com>, Rob Tweed wrote:
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?


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>
Jul 17 '05 #20

"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2h************@uni-berlin.de...
In article <ut********************************@4ax.com>, Rob Tweed wrote:
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?


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.


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

Jul 17 '05 #21

"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2h************@uni-berlin.de...
In article <c8**********@ctb-nnrp2.saix.net>, Justin Wyer wrote:
Tim Van Wassenhove wrote:
In article <c8**********@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 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

Jul 17 '05 #22
Tony Marston wrote:
"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2h************@uni-berlin.de...
In article <ut********************************@4ax.com>, Rob Tweed wrote:
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?


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.

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.


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.
Jul 17 '05 #23
Tony Marston wrote:
"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2h************@uni-berlin.de...
In article <c8**********@ctb-nnrp2.saix.net>, Justin Wyer wrote:
Tim Van Wassenhove wrote:

In article <c8**********@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 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.

Quite impressive Tony, smarty just works easier for me, I don't normally
invent wheels I use readily avalible ones to build cars.
Jul 17 '05 #24

"Justin Wyer" <ju****@isogo.co.za> wrote in message
news:c8**********@ctb-nnrp2.saix.net...
Tony Marston wrote:
"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2h************@uni-berlin.de...
In article <c8**********@ctb-nnrp2.saix.net>, Justin Wyer wrote:

Tim Van Wassenhove wrote:

>In article <c8**********@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 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.

Quite impressive Tony, smarty just works easier for me, I don't normally
invent wheels I use readily avalible ones to build cars.


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

Jul 17 '05 #25
Tony Marston wrote:
"Justin Wyer" <ju****@isogo.co.za> wrote in message
news:c8**********@ctb-nnrp2.saix.net...
Tony Marston wrote:

"Tim Van Wassenhove" <eu**@pi.be> wrote in message
news:2h************@uni-berlin.de...
In article <c8**********@ctb-nnrp2.saix.net>, Justin Wyer wrote:
>Tim Van Wassenhove wrote:
>
>
>>In article <c8**********@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
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.


Quite impressive Tony, smarty just works easier for me, I don't normally
invent wheels I use readily avalible ones to build cars.

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?


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.
Jul 17 '05 #26

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: lozd | last post by:
Would appreciate any solutions people could offer for this. Basically I wan't to use a frameset with an aspx page as the contents rather than a htm page and I'd like to be able to redirect the...
1
by: Stu | last post by:
Hi All, I have an ASP.NET application to which I have implemented forms authentication to handle security. It is a relatively straight forward solution with all aspx pages residing in the root...
4
by: Greg Smalter | last post by:
Redirecting from page to page within a web project is pretty easy. However, all Redirect methods take strings as arguments, as if you mistype the string, you don't find out until run time that you...
4
by: deepukutty | last post by:
HI all, I am using IE(Internet Explorer) as my default browser for asp.net application development. Today i faced a strange problem. When ever an exception occured in the page ....application...
3
by: Shreyas | last post by:
I am a new user writing some scripts to store data entered via a browser into a database. I have several content pages, and one "processing" page. A content page often has a form like this: ...
8
by: Morpheus | last post by:
I am trying to test a function that outputs text to the standard output, presumably using a cout call. I do not have access to the source, but need to test the output. Is this possible? I can...
41
by: amygdala | last post by:
Hello all, I have posted a similar question in comp.lang.php in the past, but haven't had any response to it then. I kinda swept the problem under the rug since then. But I would really like to...
1
by: Andra | last post by:
Hello! I'm a beginner in asp sorry for bothering with silly questions, but i have this problem and i hoped u could help me: I have a control which leads from different pages to a page wich has the...
9
by: Jonathan Wood | last post by:
I've spent days trying to come up with a solution. I'd appreciate it if anyone can help. My site requires all users to log on. There are three different roles of users, and each user type will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.