On Wed, Nov 19, 2003 at 08:18:32AM +0100, Miroslav I. wrote:
: 
: #The problem:
: This is about protecting my PHP from bad input (e.g.: letters instead
: of numbers).

Good idea.  You need to make sure user-inputted data is valid.

: ##
: Is there a way to prevent user from even inputting a letter in a text
: box?

There's two general ways to do data validation: client-side and
server-side.  PHP is server-side.  JavaScript is client-side.

With PHP, you allow the user to enter any data in the textbox, then code
in logic to check for illegal characters (e.g. no letters in a textbox
for one's phone number).  Of course you must also code a nice response
to let the user know when the data is found to be illegal, repost the
form, etc.

With JavaScript, you can do data validation as they press the submit
button, or even disallow illegal characters as they type in a textbox.
The response is far more immediate and thus far more effective, IMHO.
Of course, if the user's web browser isn't running JavaScript, bad data
may still slip through.  Then you must use PHP and do server-side data
validation.

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

Reply via email to