Re: Function return

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

 



On 11/2/07, Dan Shirah <mrsquash2@xxxxxxxxx> wrote:
>
> Ah, okay.  So I could probably simplfy it more by trimming it from the
> start like this??
>
> $due_date = trim($_POST['due_date']);
>


that works;
i personally prefer to initialize a variable then only set it if the
user input meets some
conditions; its called white-box validation.

$due_date = '';

if(isset($_POST['due_date'])) && !empty($POST['due_date'])) {
    $due_date = trim($_POST['due_date']);
}

the more you know about what the contents of due_date are supposed to be, the
stronger you can make the check; for instance here, it sounds like it
should be a date
so you wouldnt allow, say 'somecrazySting', to pass the validation.

-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