html用户登录注册页面代码
Below is a simple HTML code for a user login and registration page:
html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Login & Registration</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
form {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input[type="text"],
input[type="password"],
input[type="submit"] {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box;
}
input[type="submit"] {
background-color: #4caf50;
color: white;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<form id="loginForm" action="login.php" method="post">
<h2>Login</h2>
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<input type="submit" value="Login">
</form>
<form id="registerForm" action="register.php" method="post">
<h2>Register</h2>
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<input type="submit" value="Register">
</form>
</body>
</html>
In this code:
There are two forms, one for login and another for registration.Each form contains input fields for username and password.The action attribute of the forms is set to the server-side scripts (login.php
and register.php
) that handle form submission.Basic CSS is included to style the forms and make them visually appealing.
Sure, here is a continuation of the HTML code with explanations:
html<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>User Login & Registration</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
form {
background-color: #fff;
padding: 20px;
border-radius: 5px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
input[type="text"],
input[type="password"],
input[type="submit"] {
width: 100%;
padding: 10px;
margin: 5px 0;
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box;
}
input[type="submit"] {
background-color: #4caf50;
color: white;
cursor: pointer;
}
input[type="submit"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<form id="loginForm" action="login.php" method="post">
<h2>Login</h2>
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<input type="submit" value="Login">
</form>
<form id="registerForm" action="register.php" method="post">
<h2>Register</h2>
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<input type="submit" value="Register">
</form>
</body>
</html>
In this code snippet:
The HTML document begins with the <!DOCTYPE html>
declaration, specifying the document type and version.The <head>
section contains metadata such as character encoding, viewport settings, and the title of the document.Basic CSS styles are embedded within <style>
tags to enhance the visual appearance of the forms.Two forms are defined: one for user login (loginForm
) and another for user registration (registerForm
).Each form consists of input fields for username and password, with appropriate placeholders and attributes like required
.The action
attribute of each form specifies the URL to which the form data should be submitted upon submission.The method
attribute of each form specifies the HTTP method (POST) to be used for form submission.
You would need to handle form submission on the server-side using a programming language such as PHP or JavaScript.