要實現一個簡單的登錄頁面,可以按照以下步驟進行:
<!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.";
}
}
?>
以上是一個簡單的示例,實際中需要結合數據庫存儲用戶信息,并使用加密技術保護用戶密碼。