I'm writing a script that takes a submitted form and adds it to the database. Before doing so however, the script verifies certain fields and checks to make sure that they are ok before adding them.
In the case of one field, I check to make sure that it has only numeric characters. So, I use a regular expression that checks for non-digit characters. Here's the code ...
PHP Code:
if (ereg("\D", $values['thread']))
{
$msgs[] = "The Thread ID must hold numeric values only.<br />";
$values['thread'] = "";
}
Problem is: it doesn't work. It always says that there are non-digit characters, even when I enter only numbers. The field has a max size of 5, and even if I enter 5 numbers, it's incorrect.
Can someone help me out here? Thanks.
|