项目名称:基于php+MySQL的学生信息管理系统
本系统是一个用于管理学生信息的管理系统,包括基本的增删改查,系统使用PHP语言开发,使用MySQL数据库,可以供初学者参考使用。
系统环境
MySQL5.1.51-community
PHP7.3.29
1、登陆页面
2、首页
3、添加学生
4、修改学生
5、项目结构
部分核心代码
LoginController
<?php include '../dao/LoginDao.php'; include '../bean/res.php'; header("Content-Type: application/json;charset=UTF-8"); // 从请求中获取原始数据 $json = file_get_contents('php://input'); // 将其转换为 PHP 对象 $data = json_decode($json); //$param = json_encode($data); $loginDao = new LoginDao(); $res = $loginDao->login($data->uname, $data->upass); $result = new Res(); if($res){ $result->setSuccess(true); $result->setData("登录成功"); }else{ $result->setSuccess(false); $result->setData("登录失败"); } echo json_encode($result); ?>
StudentController
<?php include '../bean/User.php'; include '../dao/StudentDao.php'; header("Content-Type: application/json;charset=UTF-8"); // 从请求中获取原始数据 $json = file_get_contents('php://input'); // 将其转换为 PHP 对象 $param = json_decode($json); $method = $param->method; $studentDao = new StudentDao(); $res = new Res(); switch ($method){ case 'queryAll': //查询全部 $res->setData($studentDao->queryAll()); $res->setSuccess(true); break; case 'save': //保存 $res->setData($studentDao->save($param)); $res->setSuccess(true); break; case 'update': //更新 $res->setData($studentDao->update($param)); $res->setSuccess(true); break; case 'delete': //删除 $res->setData($studentDao->delete($param)); $res->setSuccess(true); break; } echo json_encode($res); ?>
搜索关注微信公众号:小诸葛的博客,回复105免费获取项目源代码.
- 海报