HTML登录页面的实现基本步骤如下:
<form action="login.php" method="post"> 用户名:<input type="text" name="username"> 密码:<input type="password" name="password"> <input type="submit" value="登录"> </form>
// 接收表单数据 $username = $_POST['username']; $password = $_POST['password']; // 连接数据库 $pdo = new PDO("mysql:host=localhost;dbname=test", "root", "123456"); // 查询数据库 $sql = "SELECT * FROM users WHERE username='$username' AND password='$password'"; $result = $pdo->query($sql); $row = $result->fetch(); // 判断登录是否成功 if ($row) { echo "登录成功!"; } else { echo "登录失败!"; }
本文链接:http://task.lmcjl.com/news/5303.html