Home > Backend Development > PHP Tutorial > PHP student management system implementation_PHP tutorial

PHP student management system implementation_PHP tutorial

WBOY
Release: 2016-07-13 10:13:09
Original
1261 people have browsed it

PHP student management system implementation

The school recently opened a PHP course, so I wrote an assignment and would like to share it. . .


These are very simple things that novices can use...,,

Omit some front-end code,,,

The first is the login verification:

<?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

Then there is the registration verification:

<?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


Graduation operation and adding history verification:

<?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

Any keyword query:


<?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

Traverse student information:

<!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

Update data page and verification:

<!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>
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

Some front-end design:


<!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




www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/917112.htmlTechArticlePHP student management system implementation. Recently, the school has opened a PHP course, and I wrote an assignment by the way. Let me share it. . . They are all very simple things that novices can use... Omit some front-end code...
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template