---------------------------------Form登录表单---------------------------------------- <!DOCTYPE html> <html> <head> <title>登录验证</title> </head> <body> <form action="yanzhen.php" method="get"> <p>帐号:<input type="text" name="username"/></p> <p>密码:<input type="text" name="password"></p> <input type="submit" value="登录"> </form> </body> </html>
---------------------------------PHP登录验证----------------------------------------
<!DOCTYPE html>
<html>
<body>
<?php
$servername = "127.0.0.1";
$username = "root";
$password = "root";
$dbname = "mysql";
// 创建连接
$conn = new mysqli($servername, $username, $password, $dbname);
// 检查链接
if ($conn->connect_error) {
die("连接失败: " . $conn->connect_error);
}
$user_name=$_GET['username'];//获取用户名和密码
$password=$_GET['password'];
$sql = "SELECT username,password FROM name where username='"."$user_name"."' and password='"."$password"."'";
$result = mysqli_query($conn,$sql);
if(mysqli_num_rows($result) > 0) {
echo "登录成功";
} else {
echo "查询失败";
}
mysqli_close($conn);
?>
</body>
</html>
---------------------------------登录验证图----------------------------------------
---------------------------------防SQL待提供----------------------------------------
打赏我,让我更有动力~
© 2016 - 2024 掌控者 All Rights Reserved.
Track-方丈
发表于 2018-6-11
通过。
评论列表
加载数据中...