html用户登录界面代码
时间: 2023-12-07 22:03:45 浏览: 9
<!DOCTYPE html>
<html>
<head>
<title>User Login</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<div class="login-wrapper">
<h2>User Login</h2>
<form>
<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">
</form>
</div>
</body>
</html>
相关问题
好看html用户登录界面代码
以下是一个简单的 HTML 用户登录界面的代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>User Login</title>
<style type="text/css">
body {
background-color: #f2f2f2;
font-family: Arial, sans-serif;
}
form {
background-color: #fff;
color: #333;
padding: 20px;
max-width: 500px;
margin: 50px auto;
border-radius: 5px;
box-shadow: 0px 0px 10px #aaa;
}
h1 {
text-align: center;
margin-bottom: 30px;
}
input[type="text"], input[type="password"] {
display: block;
width: 100%;
padding: 10px;
margin-bottom: 20px;
border-radius: 5px;
border: none;
box-shadow: 0px 0px 5px #aaa;
font-size: 16px;
font-family: Arial, sans-serif;
}
input[type="submit"] {
background-color: #4CAF50;
color: #fff;
padding: 10px 20px;
border: none;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
margin-top: 20px;
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
</style>
</head>
<body>
<form action="#" method="post">
<h1>User Login</h1>
<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="Log In">
</form>
</body>
</html>
```
这段代码会生成一个包含用户名和密码输入框的表单,并且在点击“Log In”按钮时提交表单。你可以根据自己的需要进行修改和调整。
php用户登录界面代码
以下是一个简单的 PHP 用户登录界面代码:
```
<?php
session_start(); // 开始新的或者继续已经存在的会话
$error = ''; // 初始化错误变量
if (isset($_POST['submit'])) {
if (empty($_POST['username']) || empty($_POST['password'])) {
$error = "用户名或密码不能为空";
} else {
// 验证用户输入的用户名和密码是否正确
$username = $_POST['username'];
$password = $_POST['password'];
$conn = mysqli_connect("localhost", "root", "", "database_name");
$query = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = mysqli_query($conn, $query);
if (mysqli_num_rows($result) == 1) {
$_SESSION['login_user'] = $username; // 在会话中存储用户名
header("location: welcome.php"); // 重定向到欢迎页面
} else {
$error = "用户名或密码不正确";
}
mysqli_close($conn); // 关闭数据库连接
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>用户登录</title>
</head>
<body>
<h2>用户登录</h2>
<form method="post" action="">
<label>用户名:</label>
<input type="text" name="username"><br><br>
<label>密码:</label>
<input type="password" name="password"><br><br>
<input type="submit" name="submit" value="登录">
<span><?php echo $error; ?></span>
</form>
</body>
</html>
```
注意:这只是一个简单的示例代码,如果要在实际项目中使用,请根据需要进行修改和完善。