"");/*在后台再进行一次数据校验*/$username = $_POST['username'];$pass..._php+js的简单用户管理系统">
当前位置:   article > 正文

php和mysql实现学生管理系统,js+php+mysql实现的学生成绩管理系统

php+js的简单用户管理系统

js+php的简单学生管理系统,自己建个students的数据库

实现的效果如下图所示:

注册

604c9a15029b4d72aac89bf8015510b4.jpg

登录

2cb63678f4a34c61af5eb11add37be4a.jpg

系统主页

9ee3728675a14c78a15ce0489b49fad3.jpg

新增页面

a8a625fb92b1465a9cbb548df1a23677.jpg

修改页面

ef6057493a34454fa12958f0f42eebc7.jpg

注册页面--register.html

Document

注册

用户名:

密码:

确认密码:

...

注册的php代码-register.php

0, "msg" => "");

/*

在后台再进行一次数据校验

*/

$username = $_POST['username'];

$password = $_POST['password'];

$repassword = $_POST['repassword'];

$createTime = $_POST['createTime'];

//1、判断用户名是否存在

if(!$username){

$responseData['code'] = 1;

$responseData['msg'] = "用户名不能为空";

echo json_encode($responseData);

exit;

}

if(!$password){

$responseData['code'] = 2;

$responseData['msg'] = "密码不能为空";

echo json_encode($responseData);

exit;

}

if($password != $repassword){

$responseData['code'] = 3;

$responseData['msg'] = "两次输入不一致";

echo json_encode($responseData);

exit;

}

$link = mysqli_connect("127.0.0.1", "root", "123456abc");

if(!$link){

$responseData['code'] = 4;

$responseData['msg'] = "服务器忙";

echo json_encode($responseData);

exit;

}

mysqli_set_charset($link, "utf8");

mysqli_select_db($link, "qd2002");

$sql = "SELECT * FROM users WHERE username='{$username}'";

//mysql result

$res = mysqli_query($link, $sql);

//取出一行

$row = mysqli_fetch_assoc($res);

//已经注册

if($row){

$responseData['code'] = 5;

$responseData['msg'] = "用户名已经存在";

echo json_encode($responseData);

exit;

}

//加密

$str = md5(md5(md5($password).'qianfeng').'xiaoming');

//准备sql,插入

$sql2 = "INSERT INTO users (username,password,createTime) VALUES('{$username}','{$str}',{$createTime})";

$res = mysqli_query($link, $sql2);

if($res){

$responseData['msg'] = "注册成功";

echo json_encode($responseData);

}else{

$responseData['code'] = 6;

$responseData['msg'] = "注册失败";

echo json_encode($responseData);

exit;

}

mysqli_close($link);

?>

登录页面-login.html

Document

登陆

用户名:

密码:

...

登录页面-login.php

0, "msg" => "");

/*

在后台再进行一次数据校验

*/

$username = $_POST['username'];

$password = $_POST['password'];

//1、判断用户名是否存在

if(!$username){

$responseData['code'] = 1;

$responseData['msg'] = "用户名不能为空";

echo json_encode($responseData);

exit;

}

if(!$password){

$responseData['code'] = 2;

$responseData['msg'] = "密码不能为空";

echo json_encode($responseData);

exit;

}

//天龙八部

//1、链接数据库

$link = mysqli_connect("127.0.0.1", "root", "123456abc");

//2、判断数据库是否链接成功

if(!$link){

$responseData['code'] = 4;

$responseData['msg'] = "服务器忙";

echo json_encode($responseData);

exit;

}

//3、设置访问字符集

mysqli_set_charset($link, "utf8");

//4、选择我们要访问的数据库

mysqli_select_db($link, "qd2002");

//5、准备sql语句,进行登陆

//加密

$str = md5(md5(md5($password).'qianfeng').'xiaoming');

$sql = "SELECT * from users WHERE username='{$username}' AND password='{$str}'";

//6、发送sql语句

$res = mysqli_query($link, $sql);

//查询,取出其中的行

$row = mysqli_fetch_assoc($res);

// var_dump($row);

if($row){

$responseData['msg'] = "登陆成功";

echo json_encode($responseData);

}else{

$responseData['code'] = 5;

$responseData['msg'] = "用户名或密码错误";

echo json_encode($responseData);

exit;

}

mysqli_close($link);

?>

主页面 show.html

<

Document

学生成绩管理系统

获取学生成绩

添加学生成绩

学生学号

学生姓名

语文成绩

数学成绩

英语成绩

操作

学生姓名:

语文成绩:

数学成绩:

英语成绩:

取消

确定

通过ajax传数据-ajax.js

export{

post,

get,

ajax

}

function post(){

var argus =Object.assign({"method" :"post"},...arguments)

var g = new Ajax(argus);

g.init();

g.type()

}

function get(){

var argus =Object.assign({"method" :"get"},...arguments)

var g = new Ajax(argus);

g.init();

g.type()

}

// function ajax(){

// var a =new Ajax(...arguments);

// a.init();

// a.type();

// }

function ajax(){

var a = new Ajax(...arguments);

a.init();

a.type()

}

class Ajax{

constructor({method,url,data,success,error}){

this.method = method;

this.url = url;

this.data = data;

this.success = success;

this.error = error;

}

init(){

var xhr = null;

try{

xhr = new XMLHttpRequest;

}catch{

xhr = new ActiveXObject("XMLHTTP");

}

return xhr;

}

type(){

var xhr= this.init()

var querystring=""

if(this.data){

querystring = this.queryString(this.data);

}

if(this.method=="get"){

xhr.open(this.method,this.url+"?"+querystring,true);

xhr.send();

}else{

xhr.open(this.method,this.url,true);

xhr.setRequestHeader('content-type', "application/x-www-form-urlencoded");

xhr.send(querystring);

}

xhr.onreadystatechange = ()=>{

if(xhr.readyState ==4){

if(xhr.status==200){

if(this.success){

this.success(xhr.responseText)

}

}else{

if(this.error){

this.error("error"+xhr.status)

}

}

}

}

}

queryString(dataObj){

var str='';

for(var attr in dataObj){

str+=`${attr}=${dataObj[attr]}&`

}

return str.substring(0,str.length-1)

}

}

分页-paging.php

$page,

"count" => $count,

"pages" => $pages,

"limit" => $limit,

"skip" => $skip,

"userlist" => array()

);

$sql2 = "SELECT * FROM students LIMIT {$skip}, {$limit}";

$res2 = mysqli_query($link, $sql2);

while($row2 = mysqli_fetch_assoc($res2)){

array_push($msg['userlist'], $row2);

}

echo json_encode($msg);

mysqli_close($link);

?>

数据添加 insert.php

数据删除 delete.php

数据修改-查找update.php

数据修改-更新 update1.php

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/凡人多烦事01/article/detail/469829
推荐阅读
相关标签
  

闽ICP备14008679号