michela Posted October 20, 2005 Share Posted October 20, 2005 if (!(strlen($_POST['student_id']) >= 6 && strlen($_POST['student_id']) <= ) { error ('Student ID number is either too long or too short!\\n'. 'Please enter your 7 digit student ID number'); This is what I am using to make sure the user only inputs 7 numbers for their student id number, would anyone know how to make sure that it is exactly 7 numbers and not a space added in the middle? Student id numbers are all like this - 1234567 I wish to avoid - 123 567 thanks Quote Link to comment https://forums.phpfreaks.com/topic/2705-php-and-mysql/ Share on other sites More sharing options...
effigy Posted October 20, 2005 Share Posted October 20, 2005 [!--PHP-Head--][div class=\'phptop\']PHP[/div][div class=\'phpmain\'][!--PHP-EHead--]if (preg_match(\'/^\d{7}$/\', $user_input)) { echo \'it is ok\'; }[/span][!--PHP-Foot--][/div][!--PHP-EFoot--] Quote Link to comment https://forums.phpfreaks.com/topic/2705-php-and-mysql/#findComment-9024 Share on other sites More sharing options...
michela Posted October 21, 2005 Author Share Posted October 21, 2005 works perfect, Thank YOU!! Quote Link to comment https://forums.phpfreaks.com/topic/2705-php-and-mysql/#findComment-9041 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.