如何使用PHP检查用户ID上的3个初始数字


How to check 3 initial digit on the User ID with PHP?

首先,如果我的英语不好,我很抱歉。我想问一下如何检查用户ID上的3个首字母数字?例如,对于我在大学的系,学生编号06411111是信息学工程系的,这是因为3的首字母数字(064)是信息学工程学系的代码。我想制作一个验证表,其中用户id一开始没有064,他们不是信息学工程专业的学生。这是我的代码:

$userid = $_POST['userid'];
$password = $_POST['password'];
$check_digit = strlen($userid);
$check_digit2 = strlen($password);
if($check_digit == 8 || $check_digit == 12){
    if (!eregi("[0-9]", $userid)){
        echo" <script language='JavaScript'> alert ('User id contain only numeric characters.');</script>";} else {
            if($check_digit2 >= 7){
                $encrypt=md5($password);} else { echo" <script language='JavaScript'> alert ('The length of the password must be >= 7.');</script>";}
                 } }else {
                            echo" <script language='JavaScript'> alert ('The length of the user id must be 8 or 12 digits');</script>";
                 }  

提前感谢你的帮助,如果我的英语不好,我再次感到抱歉(之前因为问题不清楚而收到警告)。

if(strpos($userid, '064') === 0)
  echo 'You are in ICT';
else
  echo 'You are not';