web登录注册页面代码
时间: 2023-10-15 07:02:47 浏览: 34
以下是一个简单的 web 登录注册页面的 HTML 和 CSS 代码示例:
```html
<!DOCTYPE html>
<html>
<head>
<title>Login/Register Page</title>
<style>
/* 样式 */
body {
font-family: Arial, sans-serif;
background-color: #f5f5f5;
}
.container {
width: 100%;
max-width: 400px;
margin: 0 auto;
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
}
h1 {
text-align: center;
}
label {
display: block;
margin-bottom: 10px;
}
input[type="text"],
input[type="password"],
input[type="email"] {
width: 100%;
padding: 10px;
border-radius: 5px;
border: none;
margin-bottom: 20px;
box-sizing: border-box;
font-size: 16px;
}
input[type="submit"] {
background-color: #4CAF50;
color: #fff;
border: none;
padding: 10px 20px;
border-radius: 5px;
font-size: 16px;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #3e8e41;
}
.error-message {
color: red;
margin-bottom: 10px;
}
</style>
</head>
<body>
<div class="container">
<h1>Login</h1>
<form action="login.php" method="post">
<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 class="error-message">
<?php if(isset($loginError)) {echo $loginError;} ?>
</div>
<hr>
<h1>Register</h1>
<form action="register.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<input type="submit" value="Register">
</form>
<div class="error-message">
<?php if(isset($registerError)) {echo $registerError;} ?>
</div>
</div>
</body>
</html>
```
你可以根据需要修改输入框类型、标签和样式。这些代码只是提供了一个基本的框架,你需要根据自己的需求进行修改。