best php practice?

    Date: 02/04/07 (PHP Community)    Keywords: php, html

     I have a question about the the 'best' (most efficient? cleanest? elegant?) way to process form data for a page. I don't know if I should process the data, update the DB, etc at the top of the page I'm displaying, or if I should handle it in a PHP file that then redirects to a page that displays HTML.

    Should I:


    index.php
    // Some code here
    include 'formProcessingStuff.php';
    // Lots of code
    include 'showBody.php';
    // Lots more code
    ?>

    or

    formsubmit.php
    //Page that processes the form

    // Tons of code that processes and validates info and updates DB

    // Now we want to give the user a page to see what he just did
    header('Location: displayContentPage.php');

    ?>


    displayContentPage.php
    // Code that shows the body of the page
    ?>


    The latter seems much cleaner and easier to see and understand and code. More encapulation to make updates easier down the line. But is this a Good Practice? Is it acceptable? What problems/drawbacks might I run into?

    Source: http://community.livejournal.com/php/537381.html

« write some code for meeeeee? || Awesome PHP Career... »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home