注册,登录(普通用户和管理员)
login.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>登录界面</title>
<style>
html{
height: 100%;
}
body{
height: 100%;
font-family: 'JetBrains Mono Medium';
display: flex;
align-items: center;
justify-content: center;
background-color: black;
}
.form-wrapper{
width: 300px;
background-color: rgb(41,45,62);
color: #ffffff;
border-radius: 2px;
padding: 50px;
}
.form-wrapper .header{
text-align: center;
font-size: 35px;
text-transform: uppercase;
line-height: 100px;
}
.form-wrapper .action{
display: flex;
justify-content: center;
}
.form-wrapper .action .btn{
width: 60%;
text-transform: uppercase;
border: 2px solid #FFFFFF;
text-align: center;
line-height: 20px;
border-radius: 20px;
cursor: pointer;
transition:0.2s;
}
</style>
</head>
<body>
<div class="form-wrapper" align="center" >
<div class="header">
用户登录
</div>
<form action="check.php" method="post">
<p>用户名:<input type="text" name="username" placeholder="手机号/邮箱" /></p>
<p>密码:<input type="password" name="password" placeholder="密码可见" /></p>
<br />
<button class="btn">登录</button>
<p>
没有账号?请
<a href="regist.html">注册</a>
</p>
<div style="clear: both;"></div>
</form>
</div>
</body>
</html>
user.html
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<title>首页</title>
<style>
html{
height: 100%;
}
body{
height: 100%;
font-family: 'JetBrains Mono Medium';
display: flex;
align-items: center;
justify-content: center;
background-color: black;
}
.form-wrapper{
width: 300px;
background-color: rgb(41,45,62);
color: #ffffff;
border-radius: 2px;
padding: 50px;
}
.form-wrapper .header{
text-align: center;
font-size: 35px;
text-transform: uppercase;
line-height: 100px;
}
.form-wrapper .action{
display: flex;
justify-content: center;
}
.form-wrapper .action .btn{
width: 60%;
text-transform: uppercase;
border: 2px solid #FFFFFF;
text-align: center;
line-height: 50px;
border-radius: 30px;
cursor: pointer;
transition:0.2s;
}
</style>
</head>
<body>
<div class="form-wrapper" align="center" >
<div class="header">
TA反馈系统
</div>
<div class="action">
<div class="btn"><a href="InsertStudent.php">添加学生记录</a></div>
</div>
<div class="action">
<div class="btn"><a href="StudentList.php">查看学生列表</a></div>
</div>
</div>
</body>
</html>
#登录逻辑:check.php(判断是不是管理员,还是普通人
check.php
<?php
header("Content-type: text/html; charset=utf-8");
$username = $_POST['username'];
$password = $_POST['password'];
$is_manager=$_POST['is_manager'];
if ($username == ''){
echo '<script>alert("请输入用户名!");history.go(-1);</script>';
exit(0);
}
if ($password == ''){
echo '<script>alert("请输入密码");history.go(-1);</script>';
exit(0);
}
$conn = new mysqli('localhost','root','root','test');
if ($conn->connect_error){
echo '数据库连接失败!';
exit(0);
}else {
$sql = "select username,password from userinfo where username = '$_POST[username]' and password = '$_POST[password]'";
$result = $conn->query($sql);
$number = mysqli_num_rows($result);
if ($number ) {
if ($username == "admin" && $password == "123456") {
header("Location: index.html");
}else{
echo '<script>window.location="user.html";</script>';
}
}else {
echo '<script>alert("用户名或密码错误!");</script>';
echo '<script>window.location="login.html";';
}
}
?>
用户注册:regist.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>用户注册