PHP 學生管理系統實現
最近學校開了PHP課程,順便寫了個作業,分享一下吧。。。
都是很簡單的東西,新手用得著、、、
省略部分前端程式碼、、、
首先是登入的校驗:
<?php session_start(); $user = $_POST['userName']; $pass = $_POST['passWord']; $_SESSION['user'] = $user; /*$Enter = $_POST['Login_undo']; 管理員登入的校驗*/ $flag = false; if($user == "Admin"&& $pass == "root") { setcookie("userName",$user,time()+1200); setcookie("userName",$pass,time()+1200); $flag = true; header('location:adminPage.php?user=' . $user); } else header('location:Login.php?login=relog'); /* // 學生登入免校驗 if($Enter) header('location:StuPage.php'); */
然後是註冊的校驗:
<?php session_start(); $s_ID = $_POST['s_ID']; $Name = $_POST['Name']; $IDcard = $_POST['IDcard']; $Major = $_POST['Major']; $sex = $_POST['sex']; $_SESSION['student'][$s_ID]['s_ID'] = $s_ID; $_SESSION['student'][$s_ID]['Name'] = $Name; $_SESSION['student'][$s_ID]['IDcard'] = $IDcard; $_SESSION['student'][$s_ID]['Major'] = $Major; $_SESSION['student'][$s_ID]['sex'] = $sex; header('location:tisi.html'); /*foreach($_SESSION['student'] as $v) { if($v == $s_ID) { header("location:stu_reg.php?action=look&msg=更新&user=employee&empno=" . $empno . "&idcard=" . $idcard); } else header("location:stu_reg.php?action=look&msg=增加&user=employee&empno=" . $empno . "&idcard=" . $idcard); }*/
畢業操作及加入歷史校驗:
<?php session_start(); $s_ID=$_GET['s_ID']; $_SESSION['history'][$s_ID]['s_ID']=$s_ID; $_SESSION['history'][$s_ID]['Name']=$_SESSION['student'][$s_ID]['Name']; $_SESSION['history'][$s_ID]['IDcard']=$_SESSION['student'][$s_ID]['IDcard']; $_SESSION['history'][$s_ID]['sex']=$_SESSION['student'][$s_ID]['sex']; $_SESSION['history'][$s_ID]['Major']=$_SESSION['student'][$s_ID]['Major']; unset($_SESSION['student'][$s_ID]); header('location:graduate.php?user=Admin&action=delete');
任意關鍵詞查詢:
<?php
session_start();
$search=$_POST['search'];
unset($_SESSION['search']);
/*echo '<pre>';
var_dump($_POST['search']);
return ;*/
foreach ($_SESSION['student'] as $k1 => $value) {
# code...
if($search==$_SESSION['student'][$k1]['s_ID']||$search==$_SESSION['student'][$k1]['IDcard']||$search==$_SESSION['student'][$k1]['Name']||$search==$_SESSION['student'][$k1]['sex']||$search==$_SESSION['student'][$k1]['Major']){
$i = 1;
$stu = $_SESSION['student'][$k1]['s_ID'];
$_SESSION['search'][$stu] = $stu;
}
}
if(isset($i))
header("location:stu_Query.php?user=Admin&action=search");
else
header("location:stu_Query.php?user=Admin&action=q_error");
遍歷學生資訊:
<!DOCTYPE HTML>
<html>
<head>
<link href="file/Style.Css" rel="stylesheet" type="text/css" />
</head>
<body>
<table width="100%" border="0" cellpadding="1" cellspacing="1" class="css_table" bgcolor='#E1E1E1'>
<?php
session_start();
$user = isset($_SESSION['user'])?$_SESSION['user']:'';
if($user =='Admin'){
if(isset($_SESSION['student'])){
foreach($_SESSION['student'] as $k1) {
echo "<tr>";
foreach($k1 as $k2=>$k3) {
echo "<td>" ;
if($k2=='s_ID') {echo "學號:" ;} else if($k2=='IDcard'){echo "身份證號:";}else if($k2=='sex'){echo "性別:";}else if($k2=='Name'){echo "姓名:";}else if($k2 =='Major'){echo "專業:";};
echo "</td>";
echo "<td>";
if($k2=='s_ID') $s_ID=$k3; echo "$k3";
echo "</td>";
}
}
}
}
?>
</table>
</body>
</html>
更新資料的頁面及校驗:
<!DOCTYPE HTML>
<!-- 使用HTML5規範,省略多餘部分 -->
<html>
<head>
<?php
session_start();
$user = isset($_SESSION['user'])?$_SESSION['user']:'';
$action = isset($_GET['action'])?$_GET['action']:'';
?>
<link href="file/Style.Css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php if($user =='Admin'&&$action==''){ ?>
<table width="100%" border="0" cellpadding="3" cellspacing="1" class="css_table" bgcolor='#E1E1E1'>
<tr class="css_menu">
<td colspan="3">
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="css_main_table">
<tr>
<td class="css_main">注意</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="css_col11"><strong><font color=#50691B>一旦確定不可更改</font></strong></td>
</tr>
<form name = "check_stu" method="post" action="check_stu.php">
<td><lable>請輸入修改學生的學號:
<input name = "c_ID" type="text" >
<input name = "submit" type="submit" value="確定">
</lable></td>
</form>
</table>
<?php }else if ($action == 'change') {?>
<form name="login_f" method="post" action="update_check.php">
<div class = "login" align="center">
<lable>可以修改的專案:</lable>
<input name = "c_ID" type="hidden" value = "<?php echo $_GET['c_ID'];?>">
<li><p>學生姓名:
<input name = "Name" type = "text" id = "Name"></p></li>
<li><p>專業:
<input name = "Major" type = "text" id = "Major"></p></li>
<li>
<p>性別:
<!-- <input name = "sex" type = "text" id = "sex"></p></li> -->
<input type="radio" name="sex" value="男"/>男
<input type="radio" name="sex" value="女"/>女 </br>
</li>
<li><p>確定修改:
<input name = "submit" type = "submit" value = "確定" >
<input class="Renew" value="重寫" type="reset" /> </p></li>
</form>
</div>
<?php }else if ($action == 'enchange') {
# code...
echo "<h1>已經改變</h1>";
}?>
</body>
</html>
<?php
session_start();
$s_ID = $_POST['c_ID'];
$Name = $_POST['Name'];
$Major = $_POST['Major'];
$sex = $_POST['sex'];
$_SESSION['student'][$s_ID]['s_ID'] = $s_ID;
$_SESSION['student'][$s_ID]['Name'] = $Name;
$_SESSION['student'][$s_ID]['Major'] = $Major;
$_SESSION['student'][$s_ID]['sex'] = $sex;
header("location:stu_Update.php?action=enchange");
一些前端設計:
<!DOCTYPE HTML>
<!-- 使用HTML5規範 -->
<html>
<head>
<title>main</title>
<link href="file/Style.Css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php session_start(); ?>
<?php
$user = isset($_SESSION['user'])?$_SESSION['user']:"";
?>
<?php
if($user == "")
{
// header("location:Login.php");
die("<script>
if(typeof(parent) != 'undefined'){
parent.window.location = 'Login.php';
}else{
window.location.href = 'Login.php';
}
</script>");
}
?>
<table width=100% border=0 cellpadding=3 cellspacing=1 class=css_table bgcolor='#E1E1E1'>
<tr class=css_menu>
<td colspan=3>
<table width=100% border=0 cellpadding=4 cellspacing=0 class=css_main_table>
<tr>
<td class=css_main>歡迎<?php echo "$user";?></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="css_col11"><strong><font color = "#0000FF">登入cookie有效時間為1200秒</a></strong></td>
</tr>
</table>
<table width="100%" border="0" cellpadding="3" cellspacing="1" class="css_table" bgcolor='#E1E1E1'>
<tr class="css_menu">
<td colspan="3">
<table width="100%" border="0" cellpadding="4" cellspacing="0" class="css_main_table">
<tr>
<td class="css_main">聯絡方式</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="css_col11"><strong><font color=#50691B>Blog:http://blog.csdn.net/p641290710</font></strong></td>
<td class="css_col11"><strong><font color=#50691B>Email:[email protected]</font></strong></td>
</tr>
</table>
<table width=100% border=0 cellpadding=3 cellspacing=1 class=css_table bgcolor='#E1E1E1'>
<tr class=css_menu>
<td colspan=3>
<table width=100% border=0 cellpadding=4 cellspacing=0 class=css_main_table>
<tr>
<td class=css_main>Github</td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="css_col11"><strong><a href="https://github.com/Joypeng" target="_blank"><font color=#50691B>點選進入本人Github</font></a></strong></td>
</tr>
</table>
</body>
</html>
相關推薦
PHP 學生管理系統實現
最近學校開了PHP課程,順便寫了個作業,分享一下吧。。。 都是很簡單的東西,新手用得著、、、 省略部分前端程式碼、、、 首先是登入的校驗: <?php session_start(); $user = $_POST['userName']; $pass
lua實現的學生管理系統
mov failed 按鈕 ogr name win -- averages com dolocal scores={"Chiese","Mathematics","English","Programming"}Mainmenu={"1-Add","2-Remove","3
C++ 實現簡單命令行學生管理系統
什麽 cos wid 屏幕 cit 環境 iterator choice umeng C++ 實現簡單命令行學生管理系統 貼吧ID: 這把問題不大 編譯環境是macOS。system(“clear”) 在windows下請換成 system(“cls”) #include
用ArrayList<E>實現簡單學生管理系統
package ArrayTest; /* * 用arrayList<E>去實現學生管理系統 */ import java.util.ArrayList; import java.util.Scanner; public class StudentSystemList { //
實驗三:用雙鏈表、靜態連結串列以及間接定址實現基本的學生管理系統
實驗目的:鞏固線性表的資料的儲存方法和相關操作,學會針對具體應用,使用線性表的相關知識來解決具體問題。 實驗內容:建立一個由n個學生成績的線性表,n的大小由自己確定,每個學生的成績資訊由自己確定,實現資料的對錶進行插入、刪除、查詢等操作。 (1)用雙鏈表實現 源程式: #incl
實驗三:用單鏈表實現基本的學生管理系統
實驗目的:鞏固線性表的資料的儲存方法和相關操作,學會針對具體應用,使用線性表的相關知識來解決具體問題。 實驗內容:建立一個由n個學生成績的線性表,n的大小由自己確定,每個學生的成績資訊由自己確定,實現資料的對錶進行插入、刪除、查詢等操作。 源程式: # ifndef LinkLis
Django學習筆記010-學生管理系統(Django實現)
Django學習筆記-學生管理系統(Django實現)筆記中僅實現了對資料的全部查詢。 下面實現新增、刪除、修改,程式碼如下。 下面的程式碼沒有對輸入框內容進行限制,如果輸入不符合規則的內容,會出現錯誤。 本篇更新完畢後Django更新暫停一段,由於工作崗位是測試工程師,後面將重點關注測
Django學習筆記008-學生管理系統(Django實現)-查詢資料庫
資料庫配置: DATABASES = { 'default': { ##資料庫引擎 'ENGINE': 'django.db.backends.mysql', ##資料庫主機地址 'HOST': '127.0.0.1',
python簡單實現學生管理系統
#!/usr/bin/env python # -*- coding: UTF-8 -*- # Author:Du Fei import os #學號,姓名,年齡,性別,身高 allStudentsList=[] #從檔案中讀取資料 def readFromFile(fileName): if
c語言實現學生管理系統
{{ int i,j,o; char a[20]; system("cls"); printf("修改學生的學號:"); scanf("%s",&a); //通過輸入需要修改資訊的學號找到他 print
python 實現學生管理系統
import pickle import hashlib import time def creat_md5(): m=hashlib.md5() m.update(str(time.time()).encode('utf-8')) return m.
C#實現簡單的學生管理系統增刪改查
1.Programs.cs using System; using System.Collections; using System.Collections.Generic; using System.Linq; using System.Text; using Syste
用ArrayList實現簡單學生管理系統
package ArrayTest; /* * 用arrayList<E>去實現學生管理系統 */ import java.util.ArrayList; import java.util.Scanner; public class StudentSyst
PHP初學者自寫學生管理系統
初寫 學生管理系統(初學者記錄) 1.後臺登陸頁面 <?php try { $o="mysql:host=127.0.0.1;dbname=testx"; $username="root"; $password="root"; $pdo
學生管理系統(實現類)
學生實現類,私有化,set/get方法。 package com.wh.entity; import java.util.Date; /** * 學生實體類 * * @author 16572 * */ public class Student { private in
JAVA用於List實現簡單的學生管理系統
作為一名JAVA的程式設計師,無論初學者也好大神也好,學生管理系統是個很好例子,初學者用陣列、list等來寫簡單的學生管理系統,大神則是用swing+資料庫做有介面的學生管理系統,廢話不多說,今天我就用List來實現學生管理系統。 學生管理系統主要針對學生,我
框架之struts2實現簡易學生管理系統(struts2檔案上傳、分層)
cn.scxh.stumanger.model包: Student java類 package cn.scxh.stumanger.model; public class Student { private int id; private int number;
基於SSM框架學生管理系統的實現
這是我一年前做的專案的,算是SSM框架入門的例項,maven管理工具所用到的倉庫私服為阿里雲的倉庫。 整個專案的目錄: jdbc.properties是對資料庫資訊的配置: #mysql version database setting jdbc.drive
學生管理系統,實現學生的增刪改查
先建立一個學生類: package com.inherit; public class Student { String name; String studentId; String gender; int grade;
學生管理系統map實現篇
<pre name="code" class="cpp">#ifndef student_h #define student_h #include<string> #include<iostream> #include<set>