要实现一个简单的登录页面,可以按照以下步骤进行:
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
</head>
<body>
<h2>Login</h2>
<form action="login.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username"><br><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password"><br><br>
<input type="submit" value="Login">
</form>
</body>
</html>
<?php
// 验证用户输入的用户名和密码,这里简单示例直接写死
$username = "admin";
$password = "123456";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$input_username = $_POST['username'];
$input_password = $_POST['password'];
if ($input_username == $username && $input_password == $password) {
echo "Login successful!";
} else {
echo "Login failed. Please check your username and password.";
}
}
?>
以上是一个简单的示例,实际中需要结合数据库存储用户信息,并使用加密技术保护用户密码。
辰迅云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读: php多线程高并发如何处理