diff --git a/studentAction.php b/studentAction.php new file mode 100644 index 0000000..15d8e6d --- /dev/null +++ b/studentAction.php @@ -0,0 +1,78 @@ + +query(iconv('UTF-8', 'UTF-8', $s_sql)); + if(@$_POST["btn"] == '录入') { + if($s_result->rowCount() != 0) + echo ""; + else { + if(!$tmp_file) { + $insert_sql = "insert into XS values('$StudentName', $Sex, '$Birthday', 0, NULL, NULL)"; + }else { + $insert_sql = "insert into XS values('$StudentName', $Sex, '$Birthday', 0, NULL, '$Picture')"; + } + $insert_result = $db->query(iconv('UTF-8', 'UTF-8', $insert_sql)); + + if($insert_result->rowCount() != 0) { + $_SESSION['StuName'] = $StudentName; + echo ""; + }else + echo ""; + } + } + if(@$_POST["btn"] == '删除') { + if($s_result->rowCount() == 0) + echo ""; + else { + list($XM, $KCS) = $s_result->fetch(PDO::FETCH_NUM); + if($KCS != 0) + echo ""; + else { + $del_sql = "delete from XS where XM ='$StudentName'"; + $del_affected = $db->exec(iconv('UTF-8', 'UTF-8', $del_sql)); + if($del_affected) { + $_SESSION['StuName'] = 0; + echo ""; + } + } + } + } + if(@$_POST["btn"] == '更新'){ + $_SESSION['StuName'] = $StudentName; + if(!$tmp_file) + $update_sql = "update XS set XB =$Sex, CSSJ ='$Birthday' where XM ='$StudentName'"; + else + $update_sql = "update XS set XB =$Sex, CSSJ ='$Birthday', ZP='$Picture' where XM ='$StudentName'"; + $update_affected = $db->exec(iconv('UTF-8', 'UTF-8', $update_sql)); + if($update_affected) + echo ""; + else + echo ""; + } + if(@$_POST["btn"] == '查询') { + $_SESSION['StuName'] = $StudentName; + $sql = "select XM, XB, CSSJ, KCS from XS where XM ='$StudentName'"; + $result = $db->query(iconv('UTF-8', 'UTF-8', $sql)); + if($result->rowCount() == 0) + echo ""; + else { + list($XM, $XB, $CSSJ, $KCS) = $result->fetch(PDO::FETCH_NUM); + $_SESSION['XM'] = iconv('UTF-8', 'UTF-8', $XM); + $_SESSION['XB'] = $XB; + $_SESSION['CSSJ'] = $CSSJ; + $_SESSION['KCS'] = $KCS; + echo ""; + } + } +?> \ No newline at end of file