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

PHP 学生管理系统实现

WBOY
Release: 2016-06-13 09:20:12
Original
1518 people have browsed it

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;);
	*/
		
	
Copy after login

然后是注册的校验:

<?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);
	}*/
Copy after login


毕业操作及加入历史校验:

<?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;);
Copy after login

任意关键词查询:


<?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");
Copy after login

遍历学生信息:

<!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>
Copy after login

更新数据的页面及校验:

<!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>
Copy after login

<?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");
Copy after login

一些前端设计:


<!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>
Copy after login




Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template