> php教程 > php手册 > PHP 学生管理系统实现

PHP 学生管理系统实现

WBOY
풀어 주다: 2016-06-13 09:20:12
원래의
1524명이 탐색했습니다.

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>已经改变</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>
로그인 후 복사




관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
최신 이슈
인기 추천
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿