web用户登录界面代码
时间: 2023-06-18 13:03:46 浏览: 553
以下是一个简单的 web 用户登录界面的代码示例,使用 HTML 和 CSS 实现:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
<style>
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
form {
background-color: white;
border: 1px solid #ccc;
border-radius: 5px;
padding: 20px;
width: 400px;
margin: 50px auto;
}
label {
display: block;
margin-bottom: 10px;
font-weight: bold;
}
input[type="text"],
input[type="password"] {
padding: 10px;
border-radius: 3px;
border: 1px solid #ccc;
width: 100%;
box-sizing: border-box;
margin-bottom: 20px;
}
input[type="submit"] {
background-color: #4CAF50;
color: white;
padding: 10px 20px;
border-radius: 3px;
border: none;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #339933;
}
.error {
color: red;
font-weight: bold;
margin-bottom: 10px;
}
</style>
</head>
<body>
<form action="login.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="Login">
<?php if(isset($error)) { ?>
<p class="error"><?php echo $error; ?></p>
<?php } ?>
</form>
</body>
</html>
```
请注意,此代码示例仅包含 HTML 和 CSS,不包括实现用户身份验证的 PHP 代码。在实际应用中,您需要将此代码与适当的服务器端代码结合使用,以验证用户凭据并将用户重定向到适当的页面。