Re: Using require instead of redirect architecture

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Dec 19, 2007 3:55 PM, Robert Erbaron <robert.erbaron@xxxxxxxxx> wrote:

> > 1.  p1.php would post to itself.  Do data validation.  After data
> validation
> >         upon error, include p1.php again with included error messages
> >         upon success, redirect to p3.php with congrats.
>
> Yeah, I could do this, but it uses a redirect, and like you said, it's
> gnarly.
>

the post to itself is a good idea; and there is nothing wrong with having
another
script as the 'welcome' script or w/e.  in order to avoid a redirect in this
case
you could simply have an include directive.
eg.
if($wasLoginSuccessul) {
    include('welcome.php');
    die;
}

not something i would do in a complex system, but in a simple system,
for-sure.


> I agree as well. But I'm trying to get away from multiple trips to the
> server for simple page calls, per some pundits on the list. :) So I'm
> trying to learn a different architecture, and I'm not getting it yet.


one thing i think of to mention is that each php script does not have to be
one that
is accessible by an end user.  you can have 'back-end' scripts that do all
sorts of
stuff.  validation for example..  you might have a class, something roughly
like
<?php
class DataValidator {
  public static function isEmailAddress($potentialEmailAddress) {
    // regex to determine if $potentialEmailAddress is valid
    return $isEmailAddressValid;
  }

  public static function isUsernameAcceptable($potentialUsername) {
    // etc..
    return $isUsernameAcceptable;
  }
}
?>

clearly this is not a script a user will access through the browser.  in
fact these are the
sort of scripts i usually stash away in /usr/share/php5/someProject
anyway, this is the best sort of generic advice i can give you on a solid
'architecture'.  if
all your scripts are designed with the premise of being accessed directly
from a client
browser youll be building a house of cards.

-nathan

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux