"boclair" <[EMAIL PROTECTED]> wrote in message
002101c0bd8e$30742e60$[EMAIL PROTECTED]">news:002101c0bd8e$30742e60$[EMAIL PROTECTED]...
| I have a problem with a user input in a form required to be an
| integer, creating a variable for a mysql query.
| I have instances where integer, 0, is being typed as letter,o.
| Does anybody know if such validation can be done server side or
| definitely must be done client side?
Brad S Jackson replied suggesting that the php function preg_match()
should be used for this type of server side validation.
----- Original Message -----
From: Brad S. Jackson <[EMAIL PROTECTED]>
To: boclair <[EMAIL PROTECTED]>
Sent: Thursday, April 05, 2001 11:54 PM
Subject: Re: [PHP-DB] Forms : Validating user input is integer
> This is probably the most efficient way to check. The preg
functions are faster
> than the ereg functions so I never use ereg. I think server side
> required and client side is optional.
> if(preg_match("/^[0-9]+$/", $var))
> echo "Valid";
> echo "Invalid";
There you go. Does the same job as Matt William's eregi()
I am getting invaluable lessons on this stuff, which I never
Using the php preg_match() function the tested script is
if ((@!$submit) || empty($num) )
echo "<div align='center'><span class='note'>No entry was
echo "<div align='center'><span class='note'>The ID should have
been a number.</span></div>";
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]