基于PHP的学生管理系统;
实现 登录、注册、学生信息、修改学生、删除学生、查询学生、添加学生等功能 ;
开发平台:PhpStrom2022.1.2 、Phpstudy_pro
数据库:MySQL5.7.26
Bootstrap +PHP7.3.4+html5+css3
1.登录与注册页面
2.首页
3.学生信息
4.修改学生
5.查询学生
6.添加学生
7.管理员信息
8.修改管理员
9.添加管理员
10.查询管理员
11.数据库
1.MySQL 版本5.0以上与8.0以上sql语句有差异,需要调整数据库语句
2.运行项目前提前配置好MySQL数据库
3.本系统实现功能仅供参考
目录
一、登录界面
二、注册页面
三、学生信息
四、添加页面
五、修改页面
六、删除
七、查询页面
八、头部代码
login.html
login.php
学生管理系统
query("set names utf8"); $user = $_POST['user']; $pwd = $_POST['pwd']; $sql = "SELECT * FROM `admin` WHERE `name` = '{$user}' and `pwd` = '{$pwd}' "; $stmt= $conn->query($sql); $result = mysqli_fetch_array($stmt); if($stmt->num_rows > 0){ $_SESSION['user'] = $result[0]; echo ""; echo ""; }else{ echo ""; echo ""; }
register.html
register.php
管理员注册
query("set names utf8"); $user = $_POST['user']; $pwd1 = $_POST['pwd1']; $pwd2 = $_POST['pwd2']; $rows = "select `name` from `admin` where `name` = '{$user}'"; $stmt1= $conn->query($rows); $row = mysqli_num_rows($stmt1); if ($row == 1){ echo ""; echo (""); } elseif ($pwd1 == $pwd2){ $sql = "insert into `admin` (`name`, `pwd`) value ('{$user}','{$pwd1}')"; $conn->query($sql); echo (""); echo (""); } else{ echo ""; echo (""); } $conn->close();
student.php
学生信息
学生信息展示
姓名 | 学号 | 性别 | 手机号 | 班级 | 操作 |
---|---|---|---|---|---|
{$stu['user']} | "; echo "{$stu['id']} | "; echo "{$stu['gender']} | "; echo "{$stu['phone']} | "; echo "{$stu['class']} | "; echo "删除 修改 | "; echo "
add.php
add2.php
主页
添加学生
query("set names utf8"); $user = $_POST['user']; $id = $_POST['id']; $gender = $_POST['gender']; $phone = $_POST['phone']; $class = $_POST['class']; $rows = "select `id` from `student` where `id` = '{$id}'"; $stmt1= $conn->query($rows); $row = mysqli_num_rows($stmt1); if ($row == 1){ echo ""; echo (""); }else{ $sql = "insert into `student` (`user`,`id`,`gender`,`phone`,`class`) value ('{$user}','{$id}','{$gender}','{$phone}','{$class}')"; $stmt= $conn->query($sql); if ($stmt > 0){ echo (""); echo (""); }else { echo (""); echo (""); } } $conn->close();
update.php
update2.php
update3.php
主页
学生信息修改
query("set names utf8"); $user = $_POST['user']; $id = $_POST['id']; $gender = $_POST['gender']; $phone = $_POST['phone']; $class = $_POST['class']; $rows = "select `id` from `student` where `id` = '{$id}' and `user` = '{$user}'"; $stmt1= $conn->query($rows); $row = mysqli_num_rows($stmt1); if ($row != 1){ echo ""; echo (""); }else{ $sql = "update `student` set `user` = '{$user}',`gender` = '{$gender}',`phone` = '{$phone}',`class` = '{$class}' where `id` = '{$id}'"; $stmt= $conn->query($sql); if ($stmt > 0){ echo (""); echo (""); }else { echo (""); echo (""); } } $conn->close();
query("set names utf8"); $sql = "SELECT * FROM student WHERE id =".$_GET['id']; $stmt = $conn->query($sql);//返回预处理对象 $stu = $stmt->fetch_array(MYSQLI_ASSOC);//返回结果集为数组 ?>主页
学生信息修改
delete.php
query("set names utf8"); $id = $_GET['id']; echo $id; $sql = "delete from `student` where `id` = '{$id}'"; $stmt= $conn->query($sql); if ($stmt > 0){ echo ""; echo ""; }else { echo (""); echo (""); } $conn->close();
select.php
主页
学生信息查询
姓名 | 学号 | 性别 | 手机号 | 班级 |
---|---|---|---|---|
" . $row['user'] . " | "; echo "" . $row['id'] . " | "; echo "" . $row['gender'] . " | "; echo "" . $row['phone'] . " | "; echo "" . $row['class'] . " | "; echo "