2 Unstar Star 3 Fork 0

rumosky / 学生信息管理PHPGPL-3.0

Create your Gitee Account
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
简易学生信息管理系统,仅仅是一个测试代码,仅供参考。 spread retract

Clone or download
action.php 1.59 KB
Copy Edit Web IDE Raw Blame History
如默 authored 2019-01-02 20:16 . update
<?php include("dbconfig.php");?>
<?php
//通过action的值进行对应操作与修改
switch ($_GET['action']) {
case 'add':{ //增加操作
$name = $_POST['name'];
$sex = $_POST['sex'];
$age = $_POST['age'];
$classid = $_POST['classid'];
//写sql语句
$sql = "INSERT INTO `student`(`sex`, `name`, `classid`, `age`) VALUES ('{$sex}','{$name}','{$classid}','{$age}')";
$rw = $pdo->exec($sql);
if ($rw > 0) {
echo "<script> alert('增加成功');
window.location='show.php'; //跳转到首页
</script>";
} else {
echo "<script> alert('增加失败');
window.history.back(); //返回上一页
</script>";
}
break;
}
case "del": { //获取表单信息
$id = $_GET['id'];
$sql = "DELETE FROM student WHERE id={$id}";
$pdo->exec($sql);
header("Location:show.php");//跳转到首页
break;
}
case "edit" :{ //获取表单信息
$id = $_POST['id'];
$name = $_POST['name'];
$sex = $_POST['sex'];
$classid = $_POST['classid'];
$age = $_POST['age'];
$sql = "UPDATE student SET name='{$name}',sex='{$sex}',age='{$age}',classid='{$classid}' WHERE id='{$id}'";
$rw=$pdo->exec($sql);
if($rw>0){
echo "<script>alert('修改成功');window.location='show.php'</script>";
}else{
echo "<script>alert('修改失败');window.history.back()</script>";
}
break;
}
}

Comment ( 0 )

Sign in for post a comment

PHP
1
https://gitee.com/rumosky_admin/student_information_management.git
git@gitee.com:rumosky_admin/student_information_management.git
rumosky_admin
student_information_management
学生信息管理
master

Search

131423 f1aaba0b 1899542 094922 1c74bed3 1899542