Jump to content

Archived

This topic is now archived and is closed to further replies.

michela

php and mysql

Recommended Posts

if (!(strlen($_POST['student_id']) >= 6 && strlen($_POST['student_id']) <= 8)) {

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

Share this post


Link to post
Share on other sites

[!--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--]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.