
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;
}
input[type="text"], input[type="password"] {
width: 100%;
padding: 10px;
border-radius: 5px;
border: 1px solid #ccc;
margin-bottom: 10px;
}
button {
width: 100%;
padding: 10px;
border-radius: 5px;
background-color: #4CAF50;
color: white;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<div class="container">
<h2>注册</h2> <!-- 注册表单 -->
<form action="/register" method="post"> <!-- 这里假设注册表单提交到 ’/register’ 地址 -->
<input type="text" name="username" placeholder="用户名" required><br> <!-- 用户名字段 -->
<input type="password" name="password" placeholder="密码" required><br> <!-- 密码字段 --> <!-- 登录表单 --> <!-- 这里可以添加更多字段,比如邮箱等 --> <!-- 登录表单结束 --> <!-- 登录表单提交到 ’/login’ 地址 --> <!-- 这里可以添加更多表单元素,比如按钮等 --> <!-- 表单提交按钮 --> <button type="submit">注册</button> <!-- 表单提交按钮结束 --> </form> <!-- 注册表单结束 --> <!-- 登录表单开始 --> <h2>登录</h2> <!-- 登录表单开始 --> <form action="/login" method="post"> <!-- 登录表单提交到 ’/login’ 地址 --> <!-- 这里可以添加用户名和密码输入框等表单元素 --> <!-- 表单提交按钮 --> <button type="submit">登录</button> <!-- 表单提交按钮结束 --> </form> <!-- 登录表单结束 --> </div> </body> </html> ``` 这个页面包含了两个表单:一个用于注册新用户,另一个用于登录现有用户,每个表单都有一个提交按钮,用于将用户输入的数据发送到服务器进行处理,在实际应用中,你需要将表单的 action 属性设置为正确的后端处理地址,并且需要添加适当的后端代码来处理用户输入的数据,你也需要确保你的应用具有适当的安全措施,以防止恶意用户攻击你的系统。




