php query whether the user exists
First get the user name through $_GET["username"]; then use mysqli connects to the database and uses query to query the database; if the query result is greater than 0, the user exists, otherwise the user does not exist.
query("select username from user where username ='{$username}' and password = '{$password}'"); //查询数据库中的用户名和密码 并返回集合 $sql = $conn->query("select username from user where username ='{$username}'"); $row = mysqli_fetch_assoc($sql); //取其中一行 if ($row > 0) { //判断是否存在 echo "{$username}用户存在"; } else { echo "{$username}用户不存在"; } ?>
For more PHP related knowledge, please visitPHP Chinese website!
The above is the detailed content of php query if user exists. For more information, please follow other related articles on the PHP Chinese website!