Andrew Poelstra wrote:
Quote:
On 2008-08-17, Jerry Stuckle <jstucklex@attglobal.netwrote:
Quote:
>Nicolas Bouthors wrote:
Quote:
>>Jerry Stuckle nous disait :
>>>Completely worthless. It doesn't allow you to process information
>>>posted to the page and display them, for instance.
>>Assuming the rest of the page starts with a mysql_fetch it does ;)
>>The intent is to always post to change data, and to always get to view
>>data.
>>>
>>My opinion anyway, glad you shared yours,
>>>
>> Nico
>>>
>>>
>Not at all. For instance, how are you going to post information back to
>the page, validate it, and if it's incorrect, display the data with an
>error message?
>>
>
Save the invalid data in $_SESSION and redirect back to the original page
with $_GET["err"] set or something, instead of redirecting to the success
page.
>
This is probably one of the worst ways to do it. Not only does it
require extra processing on both the server the the client, you now have
to keep track of additional data within the $_SESSION. Additionally,
you're doing the data entry on one page and validation on another -
which means if there is any change in the form, you have to update (at
least) two pages, instead of just one.
It means a lot of completely unnecessary work for both the computers and
the programmer.
Much cleaner is to post back to the same page, validate the data and if
it's good, do whatever you need with the data. As a final step (and
only a final step), just redirect to a "thank you" page or whatever else
is appropriate.
That way you're not doing unnecessary redirects for error handling and
you keep everything in one file. Much cleaner.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================