写一个html登入代码
时间: 2023-04-09 09:02:42 浏览: 151
以下是一个简单的 HTML 登录代码:
```
<!DOCTYPE html>
<html>
<head>
<title>Login Page</title>
</head>
<body>
<h2>Login</h2>
<form>
<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>
```
请注意,这只是一个基本的示例,实际上,您需要更多的代码来验证用户输入并将其与数据库中的凭据进行比较。
相关问题
写一个Django登入功能的代码
from django.contrib.auth.forms import AuthenticationForm
from django.contrib.auth import logindef my_view(request):
if request.method == 'POST':
form = AuthenticationForm(data=request.POST)
if form.is_valid():
user = form.get_user()
login(request, user)
# 登录成功,返回首页
return redirect('/')
else:
# 显示登录表单
form = AuthenticationForm()
return render(request, 'login.html', {'form': form})
写一段登入注册html代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Login/Register</title>
</head>
<body>
<h1>Login</h1>
<form action="" 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>
<h1>Register</h1>
<form action="" method="post">
<label for="new-username">Username:</label>
<input type="text" id="new-username" name="new-username"><br><br>
<label for="new-password">Password:</label>
<input type="password" id="new-password" name="new-password"><br><br>
<label for="confirm-password">Confirm Password:</label>
<input type="password" id="confirm-password" name="confirm-password"><br><br>
<input type="submit" value="Register">
</form>
</body>
</html>
阅读全文