Which script should contain the server-side validation code?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • holy moly
    New Member
    • Apr 2007
    • 7

    #1

    Which script should contain the server-side validation code?

    Hello,
    the user enters details into a form (values.php) whose action is (insert_values. php), where does the server-side validation code go?

    (I know other posts on this subject say use PHP_SELF for the action but I don't want to redo all the code)

    Where should I put the code? I tried it myself but neither way worked so probably the code is wrong for this but I know it works using the PHP_SELF method...

    [php]
    if (isset($_POST['submit']))
    {
    if(!$_POST['value1'] | !$_POST['value2'])
    {
    die('You did not fill in a required field.');
    }
    }
    [/php]
    any suggestions?
  • ronverdonk
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    The validation code should go into the script that catches and handles the form after it is submitted, e.g. insert_values.p hp.

    Ronald :cool:

    Comment

    Working...