我已使用此功能检查用户ID以避免重复,这是代码:
<?php
require_once('includes/config.php');
if(isset($_GET['Uid'])){
$Uid = $_GET['UID'];
$Uid = preg_replace('/^.*?(AP[0-9]{1,}).*?$/i', '$1', $Uid );
$query = "SELECT user_id FROM user where user_id='$Uid'";
$users = mysqli_query($link, $query);
$result = mysqli_num_rows($users);
if($result > 0)
{
echo "Username is already taken, or invalid username!";
}
else {
echo '';
}
}
?>
我想要的是,接受前2个字母作为AP,其余8个数字就像这个
AP14000001
然后检查用户ID是否重复,如果用户ID重复,则会发出警告或将其作为新ID接受
提前致谢