Page 1 of 1

I need help with form validating for numbers

Posted: Thu Mar 01, 2007 3:58 pm
by Philll
Hello I'm having real problems trying to validate numbers that have numbers like 122332 here's what i'm using now

Code: Select all

if (eregi ('^[0-9]$', stripslashes(trim($_POST['user_id'])))) { 
       $uid = escape_data($_POST['user_id']); 
    } else { 
       $uid = FALSE; 
       echo 'lol'; 
    }
Now how do I change the code to accept numbers that are more than 9 please?

Posted: Thu Mar 01, 2007 5:05 pm
by andym01480
Wouldn't ctype-digit http://uk.php.net/manual/en/function.ctype-digit.php be pretty useful?

Posted: Thu Mar 01, 2007 5:05 pm
by feyd
Please read through the stickies in the Regex board.