基于PHP和mysql的简单学生成绩管理系统

本系统主要架构图如上图所示。PS:register_check.php的自动注册代码写在check.php里了。

使用数据库的两张表,user_info用户信息表和stu_info学生成绩信息表。



提供登录服务:分为管理员登录和学生登录,若登录时输入数据库中没有的账号 和密码的时候系统会自动注册,即将新账号信息写入user_info中去。

学生登录只可以进行查询操作,管理员登录可以进行增删和查操作,注册新账号的权限都是学生。

接下来上代码:

login.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>信息查询界面</title>
<style type = "text/css">
   	a{text-decoration: none;font-size:25px;font-family:微软雅黑;color:rgb(98,94,91);}
	a:link{color:#00FFFF;}/*未访问的颜色 蓝色*/
	a:hover{color:#FF00FF;}/*鼠标放上去的颜色(没起作用) 紫色*/
	a:visited{color:#00FFFF;}/*访问过的颜色 蓝色*/
	a:active{color:#FF00FF;}/*选定的代码 紫色*/
</style>
</head>
<!--这是学生端的查询界面,不提供返回管理员页面的接口-->
<body>
<div style="font-size:25px;font-family:微软雅黑;color:rgb(98,94,91);" align="center">
	<p>请输入学生的学号进行查询操作</p>
	<p>如果要查询所有学生信息请输入“所有”进行查询</p>
</div>
<div style="height:180px;width:180px;margin:0px auto;" align="right">
	<p sytle="text-align:center;">
<img src="宅舞.gif" width="160" height="160" align="right"/>
</p>
</div>
<form action="select_opt_stu.php" method="post" style="margin: 35px auto;padding:30px;box-shadow: 1px 1px 2px 1px #aaaaaa;border-radius: 3px;width:380px;">
	<input  type="text" name="check"  style = "background-color: rgb(250, 255, 189) !important; border-radius: 3px;box-shadow: none; color: rgb(0, 0, 0);line-height: 26px;width:240px;" placeholder="请输入要查询学生的学号">
	          
	<input type="submit" value="查询" style ="height : 36px;border:1px;background-color:#00bee7;color:#fff;width:72px;border-radius: 3px;">
</form>

</body>
	</html>

check.php

<title>验证账号密码后台程序</title>
<meta charset="utf-8">
    <?php
		function get_str($str){
			$val = ($_POST[$str])?$_POST[$str]:null;
			return $val;
		}
		$user = get_str("username");
		$pass = get_str("password");
		if($user==null or $pass == null){?>
			<script type="text/javascript">
				alert("用户名或密码为空,请重新输入");
				window.location.href="login.html";
			</script>
			<?php
		}
		$con = mysql_connect("localhost","root","root") or die("数据库链接失败");
		if(!$con){
	?>
	<script type = "text/javascript">
    	alert("连接服务器失败");
		window.location.href = "login.html";
    </script>
    <?php
		}
		$sel = mysql_select_db("SGMSystem",$con) or die("数据库选择失败");
		if(!$sel){
	?>
    <script type = "text/javascript">
		alert("选择数据库失败");
		window.location.href = "login.html";
	</script>
    <?php
		}
		$sql = "select * from user_info where username = '$user'";
		//echo $sql."<br>";
		$info = mysql_query($sql,$con);
		echo $info;
		$num = mysql_num_rows($info);
		if($num == null){
			//没有查找到,表示要注册
			$ins = "insert into user_info (username,password,is_manager) values('$user','$pass',0)";
			$info1 = mysql_query($ins,$con);
				//注册成功,返回登陆界面重新登录
				?>
				<script type="text/javascript">
					alert("注册成功,返回登陆界面重新登录");
					window.location.href="login.html";
				</script>
				<?php
		}	
		else{
			//登录成功
			$row = mysql_fetch_array($info);
			//echo $row['password'];
			}
			if($row['password']==$pass){
				if($row['is_manager'] == 1){
					//是管理员
	?>
    <script type = "text/javascript">
		alert("管理员登录成功");
		window.location.href = "welcome_mag.html";
	</script>
    <?php }?>
     <?php
	 if($row['is_manager'] != 1){
		 //普通用户登录
	 	//直接进入查询界面(学生端的查询界面不提供返回服务选择界面的接口)
	?>
     <script type = "text/javascript">
		alert("普通用户登录成功");
		window.location.href = "select_stu.html";
	</script>
	<?php }
		}
		else{
	?>
	<script type = "text/javascript">
		alert("密码错误");
		window.loaction.href = "login.html";
	</script>
	<?php
		}
		mysql_close($con);
	?>

welcom_mag.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>欢迎界面</title>
<style>
	a{text-decoration: none;font-size:25px;font-family:微软雅黑;color:rgb(98,94,91);}
	a:link{color:#00FFFF;}/*未访问的颜色 蓝色*/
	a:hover{color:#FF00FF;}/*鼠标放上去的颜色(没起作用) 紫色*/
	a:visited{color:#00FFFF;}/*访问过的颜色 蓝色*/
	a:active{color:#FF00FF;}/*选定的代码 紫色*/

</style>
</head>
<div style="font-size:25px;font-family:微软雅黑;color:rgb(98,94,91);" align="center">欢迎管理员登录,您可以进行所有操作</div>
<div style="height:180px;width:180px;margin:0px auto;" align="right">
	<p sytle="text-align:center;">
<img src="宅舞.gif" width="160" height="160" align="right"/>
</p>
</div>

<div style="font-size:25px;font-family:微软雅黑;color:rgb(98,94,91);" align="center">请选择您需要的服务</div>
<div style="height:100px;width:240px;margin:0px auto;" align="center">
	<p><a href="insert.html" align="center" >输入学生成绩信息</a></p>
	<p><a href="select_mag.html" align="center">查询学生信息</a></p>
	<p><a href="delete.html" align="center">删除学生信息</a></p>
</div>
<body>
</body>
</html>

select_mag.html:

<!DOCTYPE htm
评论 27
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值