时间:2021-07-01 10:21:17 帮助过:32人阅读
//校验用户名
$userName = $_POST['username'];
if(!preg_match('/^[0-9a-zA-Z]{3,16}$/', $userName)){
die();
}
//判断用户是否已经存在
require('./../inc/pdo_conn.php');
$hPdoPre = $hPdo->prepare("SELECT user_name FROM user WHERE user_name=:username");
$hPdoPre->bindParam(':username', $userName, PDO::PARAM_STR);
$hPdoPre->execute();
$result = $hPdoPre->fetchAll();
//如果为空则可以注册
if(empty($result)){
echo 'y';
}else{
echo 'n';
}