这是一个简单的登录和注册页面的HTML代码示例。请注意,这只是一个基本的示例,不包含任何后端逻辑或数据库连接。在实际应用中,你需要添加适当的后端代码来处理用户输入和验证。此外,出于安全考虑,密码应该通过安全的方式存储和传输。
HTML代码:
<!DOCTYPE html> <html> <head> <title>登录和注册页面</title> <style> body { font-family: Arial, sans-serif; } .container { width: 300px; margin: 0 auto; } .form-group { margin-bottom: 15px; } input[type="text"], input[type="password"] { width: 100%; padding: 12px 20px; margin: 8px 0; display: inline-block; border: 1px solid #ccc; box-sizing: border-box; } button { background-color: #4CAF50; color: white; padding: 14px 20px; margin: 8px 0; border: none; cursor: pointer; width: 100%; opacity: 0.9; } </style> </head> <body> <div class="container"> <h2>登录</h2> <form action="/login" method="post"> <!-- 这里应该是处理登录的后端URL --> <div class="form-group"> <label for="username">用户名:</label> <input type="text" id="username" name="username" required> </div> <div class="form-group"> <label for="password">密码:</label> <input type="password" id="password" name="password" required> </div> <button type="submit">登录</button> <!-- 这里提交表单到后端处理 --> </form> <!-- 这里结束登录表单 --> <h2 style="margin-top: 30px;">或注册</h2> <!-- 注册表单开始前的分隔线 --> <form action="/register" method="post"> <!-- 这里应该是处理注册的后端URL --> <!-- 注册表单内容和登录表单类似,只是提交到不同的后端URL --> </form> <!-- 这里结束注册表单 --> </div> <!-- 结束容器 --> </body> </html>
上述代码中的/login
和/register
是假设的后端处理URL,你需要根据你的后端服务器设置正确的URL,这个示例没有包含任何前端验证或错误处理,所以在实际应用中你需要添加这些功能。