
下面是一个简单的 HTML 登录注册页面的代码示例。
<!DOCTYPE html>
<html>
<head>
<title>登录注册页面</title>
<style>
body {
font-family: Arial, sans-serif;
}
.container {
width: 300px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
h2 {
text-align: center;
}
label {
display: block;
margin-bottom: 10px;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
}
input[type="submit"] {
width: 100%;
padding: 10px;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<div class="container">
<h2>登录</h2>
<form action="/login" method="post"> <!-- 登录表单 -->
<label for="username">用户名:</label><br> <!-- 用户名字段 -->
<input type="text" id="username" name="username" required><br> <!-- 输入用户名 -->
<label for="password">密码:</label><br> <!-- 密码字段 -->
<input type="password" id="password" name="password" required><br> <!-- 输入密码 -->
<input type="submit" value="登录"> <!-- 登录按钮 --> <!-- 注意:实际开发中需要后端处理登录逻辑 --> <!-- 这里只是示例 --> <!-- 登录表单结束 --> </form> <!-- 注册表单开始 --> <form action="/register" method="post"> <h2>注册</h2> <label for="username">用户名:</label><br> <input type="text" id="username" name="username" required><br> <label for="email">邮箱:</label><br> <input type="email" id="email" name="email" required><br> <label for="password">密码:</label><br> <input type="password" id="password" name="password" required><br> <input type="submit" value="注册"> </form> </div> </body> </html> ``` 这个示例包括一个简单的登录和注册表单,登录表单会将用户输入的用户名和密码发送到服务器的"/login"路径,注册表单会将用户名、邮箱和密码发送到服务器的"/register"路径,这只是一个简单的示例,实际开发中需要后端处理登录和注册的逻辑,为了提高安全性,密码应该进行加密处理,并且不应该明文存储。




