I need help with form validating for numbers

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Philll
Forum Newbie
Posts: 1
Joined: Thu Mar 01, 2007 3:55 pm

I need help with form validating for numbers

Post 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?
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Post by andym01480 »

Wouldn't ctype-digit http://uk.php.net/manual/en/function.ctype-digit.php be pretty useful?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Please read through the stickies in the Regex board.
Post Reply