検索
ホームページphp教程php手册PHP 学生管理系统实现

PHP 学生管理系统实现

Jun 13, 2016 am 09:20 AM
学生マネジメントシステム

PHP 学生管理系统实现

最近学校开了PHP课程,顺便写了个作业,分享一下吧。。。


都是很简单的东西,新手用得着、、、

省略部分前端代码、、、

首先是登录的校验:

<?php 
	session_start();
	
	$user = $_POST[&#39;userName&#39;];
	$pass = $_POST[&#39;passWord&#39;];
	$_SESSION[&#39;user&#39;] = $user;
	/*$Enter = $_POST[&#39;Login_undo&#39;];
	管理员登录的校验*/
	$flag = false;
	if($user == "Admin"&& $pass == "root")
	{
		setcookie("userName",$user,time()+1200);
		setcookie("userName",$pass,time()+1200);
		$flag = true;
		header(&#39;location:adminPage.php?user=&#39; . $user);
	}
	else
		header(&#39;location:Login.php?login=relog&#39;);
	/*
	// 学生登录免校验	
	if($Enter)
	header(&#39;location:StuPage.php&#39;);
	*/
		
	

然后是注册的校验:

<?php
	session_start();
	$s_ID = $_POST[&#39;s_ID&#39;];
	$Name = $_POST[&#39;Name&#39;];
	$IDcard = $_POST[&#39;IDcard&#39;];
	$Major = $_POST[&#39;Major&#39;];
	$sex = $_POST[&#39;sex&#39;];

	$_SESSION[&#39;student&#39;][$s_ID][&#39;s_ID&#39;] = $s_ID;
	$_SESSION[&#39;student&#39;][$s_ID][&#39;Name&#39;] = $Name;
	$_SESSION[&#39;student&#39;][$s_ID][&#39;IDcard&#39;] = $IDcard;
	$_SESSION[&#39;student&#39;][$s_ID][&#39;Major&#39;] = $Major;
	$_SESSION[&#39;student&#39;][$s_ID][&#39;sex&#39;] = $sex;
	header(&#39;location:tisi.html&#39;);
	/*foreach($_SESSION[&#39;student&#39;] 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[&#39;s_ID&#39;];


	$_SESSION[&#39;history&#39;][$s_ID][&#39;s_ID&#39;]=$s_ID;
	$_SESSION[&#39;history&#39;][$s_ID][&#39;Name&#39;]=$_SESSION[&#39;student&#39;][$s_ID][&#39;Name&#39;];
	$_SESSION[&#39;history&#39;][$s_ID][&#39;IDcard&#39;]=$_SESSION[&#39;student&#39;][$s_ID][&#39;IDcard&#39;];
	$_SESSION[&#39;history&#39;][$s_ID][&#39;sex&#39;]=$_SESSION[&#39;student&#39;][$s_ID][&#39;sex&#39;];
	$_SESSION[&#39;history&#39;][$s_ID][&#39;Major&#39;]=$_SESSION[&#39;student&#39;][$s_ID][&#39;Major&#39;];

	unset($_SESSION[&#39;student&#39;][$s_ID]);

	header(&#39;location:graduate.php?user=Admin&action=delete&#39;);

任意关键词查询:


<?php
	session_start();
	
	$search=$_POST[&#39;search&#39;];
	unset($_SESSION[&#39;search&#39;]);

	/*echo &#39;<pre class="code">&#39;;
	var_dump($_POST[&#39;search&#39;]);
	return ;*/

	foreach ($_SESSION[&#39;student&#39;] as $k1 => $value) {
		# code...
		if($search==$_SESSION[&#39;student&#39;][$k1][&#39;s_ID&#39;]||$search==$_SESSION[&#39;student&#39;][$k1][&#39;IDcard&#39;]||$search==$_SESSION[&#39;student&#39;][$k1][&#39;Name&#39;]||$search==$_SESSION[&#39;student&#39;][$k1][&#39;sex&#39;]||$search==$_SESSION[&#39;student&#39;][$k1][&#39;Major&#39;]){
			$i = 1;
			$stu = $_SESSION[&#39;student&#39;][$k1][&#39;s_ID&#39;];
			$_SESSION[&#39;search&#39;][$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=&#39;#E1E1E1&#39;>
<?php
	session_start();
	$user = isset($_SESSION[&#39;user&#39;])?$_SESSION[&#39;user&#39;]:&#39;&#39;;
	if($user ==&#39;Admin&#39;){
		if(isset($_SESSION[&#39;student&#39;])){
			foreach($_SESSION[&#39;student&#39;] as $k1) { 
			echo "<tr>";
		
			foreach($k1 as $k2=>$k3) {
			echo "<td>" ;
			if($k2==&#39;s_ID&#39;) {echo "学号:" ;} else if($k2==&#39;IDcard&#39;){echo "身份证号:";}else if($k2==&#39;sex&#39;){echo "性别:";}else if($k2==&#39;Name&#39;){echo "姓名:";}else if($k2 ==&#39;Major&#39;){echo "专业:";}; 
			echo "</td>";
			echo "<td>";
			if($k2==&#39;s_ID&#39;) $s_ID=$k3;  echo "$k3"; 
			echo "</td>";
			}
		}
	}
}
?>
</table>
</body>
</html>

更新数据的页面及校验:

<!DOCTYPE HTML>
<!-- 使用HTML5规范,省略多余部分 -->
<html>
<head>
<?php 
	session_start();
	$user = isset($_SESSION[&#39;user&#39;])?$_SESSION[&#39;user&#39;]:&#39;&#39;;
	$action = isset($_GET[&#39;action&#39;])?$_GET[&#39;action&#39;]:&#39;&#39;;
?>

<link href="file/Style.Css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php if($user ==&#39;Admin&#39;&&$action==&#39;&#39;){ ?>
<table width="100%" border="0" cellpadding="3" cellspacing="1" class="css_table" bgcolor=&#39;#E1E1E1&#39;>
  <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>


</table>
<?php }else if ($action == &#39;change&#39;) {?>

	</p>
<?php }else if ($action == &#39;enchange&#39;) {
	# code...
	echo "<h1 id="已经改变">已经改变</h1>";
}?>
</body>
</html>

<?php
	session_start();
	$s_ID = $_POST[&#39;c_ID&#39;];
	$Name = $_POST[&#39;Name&#39;];
	$Major = $_POST[&#39;Major&#39;];
	$sex = $_POST[&#39;sex&#39;];

	$_SESSION[&#39;student&#39;][$s_ID][&#39;s_ID&#39;] = $s_ID;
	$_SESSION[&#39;student&#39;][$s_ID][&#39;Name&#39;] = $Name;
	$_SESSION[&#39;student&#39;][$s_ID][&#39;Major&#39;] = $Major;
	$_SESSION[&#39;student&#39;][$s_ID][&#39;sex&#39;] = $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[&#39;user&#39;])?$_SESSION[&#39;user&#39;]:"";
  ?>
  <?php
    if($user == "")
    {
      // header("location:Login.php");
      die("<script>
            if(typeof(parent) != &#39;undefined&#39;){
                parent.window.location = &#39;Login.php&#39;;
            }else{
                window.location.href = &#39;Login.php&#39;;
            }
          </script>");
    }
  ?> 
  <table width=100% border=0 cellpadding=3 cellspacing=1 class=css_table bgcolor=&#39;#E1E1E1&#39;>
    <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秒</strong></td>
    </tr>
  </table>
  <table width="100%" border="0" cellpadding="3" cellspacing="1" class="css_table" bgcolor=&#39;#E1E1E1&#39;>
    <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:pengjunweiright@163.com</font></strong></td>
    </tr>
  </table>
  <table width=100% border=0 cellpadding=3 cellspacing=1 class=css_table bgcolor=&#39;#E1E1E1&#39;>
    <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><font color=#50691B>点击进入本人Github</font></strong></td>
    </tr>
  </table>
</body>
</html>




声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

WebStorm Mac版

WebStorm Mac版

便利なJavaScript開発ツール

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

SublimeText3 英語版

SublimeText3 英語版

推奨: Win バージョン、コードプロンプトをサポート!

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

DVWA

DVWA

Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、