当前位置:网站首页>Based on php online examination management system acquisition (php graduation design)
Based on php online examination management system acquisition (php graduation design)
2022-08-01 21:32:00 【Complete source code library】
基于php在线考试管理系统
The online exam management system is based onphp编程语言,Thinkphp框架设计,mysql数据库设计,This design has two roles of candidates and administrators,Candidates can register and log in to the system,进行在线考试,提交试卷,查看得分,The administrator can log in the background to check the test questions,考试信息,在线公告,Manage roles, permissions and other functions,本系统界面美观,功能齐全,适合作为phpGraduation project and course design reference and learning.
一.技术环境
php版本:5.3 及以上
后台框架:thinkphp
开发工具: notepad++,sublime,phpstorm都可
数据库: mysql
服务器: apache
集成环境: phpstudy(或其他)
详细技术:HTML+CSS+JS+PHP+MYSQL+PhpStudy+thinkphp
二.项目文件

三.系统功能

四.代码示例
<?php
// +----------------------------------------------------------------------
// | 注册功能
// | 设计思路,首先判断用户输入的数据是否正确,在判断用户的邮箱有没有注
// | 过,满足条件,注册成功,ajaxReturn函数在include.php中
// +----------------------------------------------------------------------
//引用常用的函数
require_once('../../../config/config.php');
//获取前台发来的数据
$name = $_POST['name'];//获取用户名
$password = $_POST['password'];//获取密码
$email = $_POST['email'];//获取游戏
$password_o = $_POST['password_o'];//获取重复密码
//判断用户名
if(!$name) {
ajaxReturn(0,'用户名格式不正确,英文加数字!');
}
//判断密码是否输入正确
if(!is_password($password)) {
ajaxReturn(0,'密码格式不正确,不少于6位!');
}
//判断邮箱是否输入正确
if(!is_email($email)) {
ajaxReturn(0,'邮箱格式不正确!');
}
//判断两次密码输入是否一致
if($password != $password_o) {
ajaxReturn(0,'两次输入的密码不一致!');
}
//查询数据库是否已经注册过此邮箱
$sql = "SELECT * FROM users WHERE email='$email'";
$result1 = fetchAll($link,$sql);
if($result1) {
ajaxReturn(0,'抱歉,此邮箱已经注册过!');
}
$data = array(
'name'=>$name,
'password'=>$password,
'email'=> $email,
'addtime'=>date('Y-m-d H:i:s')
);
//保存用户的注册信息到users表,其中的$link在include.php里
$result2 = insert($link,$data,'users');
//注册成功和失败的话,返回提示
if(!$result2) {
ajaxReturn(0,'注册失败!');
}else{
ajaxReturn(1,'恭喜你注册成功');
}
<?php
// +----------------------------------------------------------------------
// | 登录功能
// | 设计思路,获取到用户输入的账号和密码,验证用户输入的数据,验证通过,
// | 保存用户的登录信息到数据库,并且生成cookie,提示用户登录成功
// +----------------------------------------------------------------------
//引用常用的函数
require_once('../../../config/config.php');
//获取登录的用户名
$name = $_POST['name'];
//获取用户的登录密码
$password = $_POST['password'];
//获取登录的角色
$role = $_POST['role'];
//判断用户输入的用户名是否为空
if (!$name) {
//如果为空,返回提示信息
ajaxReturn(0, '请输入用户名');
}
//判断用户输入的密码是否为空
if (!$password) {
ajaxReturn(0,'请输入密码');
}
//sql语句
$sql = "SELECT * FROM users WHERE name='$name' AND password='$password'";
//查询数据库用户记录,fetchOne函数在mysql.php里
$result = fetchOne($link,$sql);
//如果没有查询到此用户
if(!$result) {
ajaxReturn(0,'抱歉,登录名和密码错误!');
}else {
//保存用户的session
$user = array(
'id'=>$result['id'],
'name'=>$result['name'],
'avatar' =>$result['avatar'],
'role'=>$result['role']
);
//如果是用户登录
if($role == 1) {
if($result['role'] == 1){
//设置session,失效时间1小时
$_SESSION["user"]=$user;
ajaxReturn(1,'恭喜你,登录成功!');
}else{
ajaxReturn(0,'抱歉,你不是用户!');
}
}
//如果是管理员登录
if($role == 2 ) {
//判断是否是管理员
if($result['is_admin'] == 1) {
//设置session,失效时间1小时
$_SESSION["admin"]=$user;
//提示登录成功
ajaxReturn(2,'恭喜你,登录成功!');
}else{
//如果不是管理员,给予提示
ajaxReturn(0,'抱歉,你不是管理员!');
}
}
}
五.项目截图












边栏推荐
- JS提升:如何中断Promise的链式调用
- JVM内存结构详解
- P7215 [JOISC2020] 首都 题解
- C Pitfalls and Defects Chapter 7 Portability Defects 7.11 An Example of a Portability Problem
- How to choose Visibility, Display, and Opacity when interacting or animating
- C专家编程 第1章 C:穿越时空的迷雾 1.2 C语言的早期体验
- C expert programming
- C语言_typedef和结构体
- C Expert Programming Preface
- 数据库练习
猜你喜欢

2022牛客多校联赛第五场 题解

图的邻接矩阵存储

Jmeter combat | Repeated and concurrently grabbing red envelopes with the same user

LeetCode

JS hoisting: how to break the chain of Promise calls

Realize the superposition display analysis of DWG drawing with CAD in Cesium

正则表达式

WEB 渗透之文件类操作

HCIP---多生成树协议相关知识点

ISC2022 HackingClub白帽峰会倒计时1天!最全议程正式公布!元宇宙集结,精彩绝伦!
随机推荐
C Pitfalls and pitfalls Appendix B Interview with Koenig and Moo
基于php影视资讯网站管理系统获取(php毕业设计)
【Jmeter常用断言组件】
C陷阱与缺陷 第7章 可移植性缺陷 7.7 除法运算时发生的截断
C Expert Programming Chapter 1 C: Through the Fog of Time and Space 1.1 The Prehistoric Phase of the C Language
【Objective-C中的@synthesize】
property语法
C语言_联合体共用体引入
C pitfalls and pitfalls Chapter 8 Suggestions and answers 8.2 Answers
C陷阱与缺陷 第7章 可移植性缺陷 7.6 内存位置0
Shell编程之条件语句
C Pitfalls and Defects Chapter 7 Portability Defects 7.9 Case Conversion
C Pitfalls and Defects Chapter 7 Portability Defects 7.8 Size of Random Numbers
数字图像处理 第十二章——目标识别
R语言 线性回归的有关方法
groupByKey和reduceBykey的区别
How to make the timer not execute when the page is minimized?
C语言_枚举类型介绍
Interview Blitz 70: What are sticky packs and half packs?How to deal with it?
Appendix A printf, varargs and stdarg A.3 stdarg.h ANSI version of varargs.h