PHP 学生管理系统实现_PHP教程

WBOY
发布: 2016-07-13 10:13:09
原创
1223 人浏览过

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;) {?>

	</div>
<?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>
登录后复制




www.bkjia.comtruehttp://www.bkjia.com/PHPjc/917112.htmlTechArticlePHP 学生管理系统实现 最近学校开了PHP课程,顺便写了个作业,分享一下吧。。。 都是很简单的东西,新手用得着、、、 省略部分前端代码...
相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!