Robert Erbaron wrote:
> Maybe I'm too old a dog to teach a new trick to.
> 
> I've got the redirect example discussed a couple days ago working
> nicely. Back, Refresh, 'wrong username' - all work nicely.
> 
> But I like the idea of reducing the load on the server, maybe
> alleviating some redirect pinball. So been trying to use require
> instead, and all hell has broken loose. Clearly I'm not structuring
> these pages correctly, but I've run into a conceptual wall of what I
> should be doing.
> 
> p1.php:
> - display form
> - post to p2.php
> 
> p2. php
> - grab and validate input
> - if good, require p3.php (which says "congrats!")
> - if bad, set error message and require p1.php (which displays error
> msg and displays form again)
> 
> Problems:
> - hitting back on p2.php shows the dreaded "The page you are trying to
> view contains POST..."
> -- OK and Cancel both generated unsatisfactory results
> - hitting refresh on p2.php runs the validation again, which means the
> validation code now has to be that much more complicated to trap for a
> second attempt, blah blah blah.
> 
> So the architecture needs to look different. Been hitting my head
> against a wall - I'll be darned if I can figure out what it is.
> 

Personally, I could see two solutions.

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.

2.  p1.php would post to p2. perform data validation.
        upon error, save data into session variable, redirect back to p1.php,
                display error messages inline
        upon success, redirect to p3.php, display congrats

I personally like the second option.  It is cleaner.  Each page/script has a 
single purpose in life.
 It just makes better sense to my small little mind.

-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
       and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
    by William Shakespeare

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

Reply via email to