php简单学生成绩 管理系统 用户登录,查,增,删, - Go语言中文社区

php简单学生成绩 管理系统 用户登录,查,增,删,


在这里插入图片描述
首先通过login_in 进入登录页面 用户输入信息到login.php中 ,login.php 连接数据库判断是否账号密码是否正确。
通过验证转入welcome_mag.html页面用户选择跳入Select_mag.html查看成绩,lnsert.html插入成绩,delete.html删除成绩。
查看成绩 从页面输入信息 select_opt.php获取用户指令,连接数据库,找出相应的数据并显示。
插入成绩 从页面输入信息 mysql_opt.php获取用户指令,连接数据库,在数据库中添加信息并返回welcome页面。
删除成绩 从页面输入要删出的学号delete_opt.phpl获取指令,连接数据库,删除相应信息并返回welcome页面。
注意事项:1获取用户输入信息 2数据库使用转码,从数据库中查找文字尚未解决 只能查找数字 3连接数据库的mysqli语句 4页面跳转
5<?php 和?>的插入位置 login_in.html到login.php页面可以看到方法
数据库需要 SGMsystem库 其中包含login 用户登录表 stu_info 成绩存储表
需要软件phpSrorm wampp
在这里插入图片描述所有需要的文件 02头像 bg背景图index.css样式表
login_in.html文件++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>重新_信息登录系统标题栏显示</title>
    <link rel="stylesheet" href="css/index.css" />
</head>

<body>
<img src="css/bgImg.jpg" class="bgImg" />
<form class="content" action="login.php" method="post">
    <div class="bidTitle">学生信息管理系统</div>
    <div class="logCon">
        <div class="line"><span>账号:</span>
            <input  class="bt_input" placeholder="请输入四位账号" name="no"  tabindex="1" type="text" ></div>
        <div class="line"><span>密码:</span>
            <input  class="bt_input" placeholder="请输入密码" name="password"  tabindex="2" type="password" ></div>
        <button type="submit" class="logingBut" value="提交" >登录</button>
    </div>
</form>
</body>
login.php文件
<title>用户登录验证</title>
<meta charset="utf-8">
<?php
function get_str($str){
    $val = ($_POST[$str])?$_POST[$str]:null;
    return $val;}
    $nom = get_str("no");
    $password = get_str("password");
if($nom==null or $password==null){?>
    <script type="text/javascript">
        alert("账号或者密码不能为空");
        window.location.href="login_in.html";
    </script>
<?php
}
$con =mysqli_connect("localhost","root","");
if($con){?>
 <script type="text/javascript" >
         alert("成功连接数据库");
         // window.location.href="login_in";
 </script><?php
    mysqli_select_db($con,"sgmsystem");
    mysqli_query($con,"SET NAMES utf8"); /*转码为utf8  否则会出现乱码*/
    $sql = "select * from login where no=$nom";
    $info = mysqli_query($con, $sql);
    $num = mysqli_num_rows($info);
    if($num){
        $row = mysqli_fetch_row($info);
        if($row[2]==$password){?>
            <script type="text/javascript">
                alert("欢迎登录");
                window.location.href="welcome_mag.html";
            </script><?php
        }
    }
else{?>
        <script type="text/javascript">
            alert("账号不存在或者密码错误");
            window.location.href="login_in.html";
        </script><?php
    }}


else{?>
<script type="text/javascript">
    alert("连接数据库发生错误");
    window.location.href="login_in";
</script><?php
}

welcome_mag.html文件++++++++++++++++++++++++++++++++++++++++++++

<!DOCTYPE html>
<html lang="en">

<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>
    <link rel="stylesheet" href="css/index.css" />
</head>
<body>
<img src="css/bgImg.jpg" class="bgImg" />
<div class="content" style="position: absolute;padding: 10px;top:-60px;left:480px">
    <div class="bidTitle">欢迎管理员登录,您可以进行所有操作</div>
    <div style="height:180px;width:180px;margin:0px auto;" align="right">
        <p sytle="text-align:center;">
            <img src="css/02.png" width="160" height="160" align="right"/>
        </p>
    </div>
    <div class="bidTitle">请选择您需要的服务</div>
    <div class="logCon">
        <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>
</div>
</body>
</html>
select_mag.html文件+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
<!DOCTYPE html>
<html lang="en">
<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>
    <link rel="stylesheet" href="css/index.css" />
</head>

<body>
<img src="css/bgImg.jpg" class="bgImg" />
<div class="content" style="position: absolute;padding: 10px;top:-100px;left:480px">
    <div class="bidTitle">
        <p>请输入学生的学号进行查询操作</p>
        <p>如果要查询所有学生信息请输入“all”进行查询</p>
    </div>
    <div style="height:180px;width:180px;margin:0px auto;" align="right">
        <p sytle="text-align:center;">
            <img src="css/02.png" width="160" height="160" align="right"/>
        </p>
    </div>
    <form action="select_opt.php" method="post" class="logCon">
        <input  type="text" name="check" class="bt_input" placeholder="请输入要查询学生的学号">
        <br/>
        <input type="submit" value="查询" class="logingBut" style="width:330px;margin-left:-20px" >
    </form>
    <div style="height:100px;width:240px;margin:0px auto;" align="center">
        <br/>
        <p><a href="welcome_mag.html" align="center" >返回服务选择页面</a></p>
    </div>
</div>
</body>
</html>

select_opt.php文件++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<html>
<head>
    <title>数据库后台操作</title>
    <meta charset="utf-8">
</head>
<body>
<?php
//这个页面主要是对插入进行处理
function get_str($str){
    $val = ($_POST[$str])?$_POST[$str]:null;
    return $val;
}
$num = get_str("id");//接收学号
$name = get_str("name");//接收姓名
$class = get_str("class");//接收班级
$sex = get_str("sex");//接收性别
$chi = get_str("chinese");//接收语文成绩
$mat = get_str("math");//接收数学成绩
$eng = get_str("english");//接收英语成绩
$syn = get_str("science");//接收理综成绩
if($num==0 or $name ==null or $class == null or $sex ==null or $chi ==0 or $mat ==0 or $eng ==0 or $syn ==0){?>
    <script type="text/javascript">
        alert("数据输入有误,请重新输入");
        window.location.href="insert.html";
    </script>
    <?php
}
$sum = $chi + $mat + $eng + $syn;//计算总分
$con = mysqli_connect("localhost","root",""); /* 连接数据库*/
if(!$con){
    ?>
    <script type="text/javascript">
        alert("数据库连接失败");
        window.location.href="insert.html";
    </script>
    <?php
}
mysqli_query($con,"SET NAMES utf8");
//将这组数据写进数据库
$sql = "insert into stu_info (id,name,calss,sex,chinese,math,english,science,sum)   
			values($num,'$name','$class','$sex',$chi,$mat,$eng,$syn,$sum)";
mysqli_select_db($con,"sgmsystem");
$info = mysqli_query($con,$sql);
if($info){

    ?>
    <script type="text/javascript">
        alert("写入成功");
        window.location.href="insert.html";
    </script>
<?php
}
else{
?>
    <script type="text/javascript">
        alert("没有找到账号密码");
        window.location.href="insert.html";
    </script>
    <?php
}
?>
</body>
</html>

insert.html文++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<!DOCTYPE html>
<html lang="en">
<head>
    <title>增添学生成绩数据</title>
    <meta charset="utf-8">
    <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>
    <link rel="stylesheet" href="css/index.css" />
</head>
<body>
<img src="css/bgImg.jpg" class="bgImg" />
<div class="content" style="position: absolute;padding: 10px;top:-185px;left:480px">
    <div class="bidTitle">请填写表单以添加数据</div>
    <div style="height:180px;width:180px;margin:0px auto;" align="right">
        <p sytle="text-align:center;">
            <img src="css/02.png" width="160" height="160" align="right"/>
        </p>
    </div>
    <form action="mysql_opt.php" method="post" class="logCon" >
        <ul style="list-style: none">
            <li>
                学号:<input type="text" name="id" class ="bt_input" style="height:5px" placeholder="请输入学号(唯一)">
            </li>
            <li>
                姓名:<input type="text" name="name" class ="bt_input" style="height:5px" placeholder="请输入姓名">
            </li>
            <li>
                班级:<input type="text" name="class" class ="bt_input" style="height:5px" placeholder="请输入班级(可全使用字符)">
            </li>
            <li>
                性别:<input type="text" name="sex" class ="bt_input"  style="height:5px" placeholder="请输入性别">
            </li>
            <li>
                语文:<input type="text" name="chinese" class ="bt_input" style="height:5px" placeholder="请输入语文成绩(满分150)">
            </li>
            <li>
                数学:<input type="text" name="math" class ="bt_input" style="height:5px" placeholder="请输入数学成绩(满分150)">
            </li>
            <li>
                英语:<input type="text" name="english" class ="bt_input" style="height:5px" placeholder="请输入英语成绩(满分150)">
            </li>
            <li>
                理综:<input type="text" name="science" class ="bt_input" style=";height:5px" placeholder="请输入英语成绩(满分300)">
            </li>

        </ul>
        <input type="submit" value="提交" style ="height : 36px;border:1px;background-color:#00bee7;color:#fff;width:72px;border-radius: 3px;">
    </form>
    <div style="height:100px;width:240px;margin:0px auto;" align="center">
        <br/>
        <a href="welcome_mag.html" align="center" style="height:10px" >返回服务选择页面</a></div>
</div>
</body>
</html>

mysql_opt.php文件++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<html>
<head>
    <title>数据库后台操作</title>
    <meta charset="utf-8">
</head>
<body>
<?php
//这个页面主要是对插入进行处理
function get_str($str){
    $val = ($_POST[$str])?$_POST[$str]:null;
    return $val;
}
$num = get_str("id");//接收学号
$name = get_str("name");//接收姓名
$class = get_str("class");//接收班级
$sex = get_str("sex");//接收性别
$chi = get_str("chinese");//接收语文成绩
$mat = get_str("math");//接收数学成绩
$eng = get_str("english");//接收英语成绩
$syn = get_str("science");//接收理综成绩
if($num==0 or $name ==null or $class == null or $sex ==null or $chi ==0 or $mat ==0 or $eng ==0 or $syn ==0){?>
    <script type="text/javascript">
        alert("数据输入有误,请重新输入");
        window.location.href="insert.html";
    </script>
    <?php
}
$sum = $chi + $mat + $eng + $syn;//计算总分
$con = mysqli_connect("localhost","root",""); /* 连接数据库*/
if(!$con){
    ?>
    <script type="text/javascript">
        alert("数据库连接失败");
        window.location.href="insert.html";
    </script>
    <?php
}
mysqli_query($con,"SET NAMES utf8");
//将这组数据写进数据库
$sql = "insert into stu_info (id,name,calss,sex,chinese,math,english,science,sum)   
			values($num,'$name','$class','$sex',$chi,$mat,$eng,$syn,$sum)";
mysqli_select_db($con,"sgmsystem");
$info = mysqli_query($con,$sql);
if($info){

    ?>
    <script type="text/javascript">
        alert("写入成功");
        window.location.href="insert.html";
    </script>
<?php
}
else{
?>
    <script type="text/javascript">
        alert("没有找到账号密码");
        window.location.href="insert.html";
    </script>
    <?php
}
?>
</body>
</html>

delete.html文件+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<!DOCTYPE html>
<html lang="en">
<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>
    <link rel="stylesheet" href="css/index.css" />
</head>
<body>
<img src="css/bgImg.jpg" class="bgImg" />
<div class="content" style="position: absolute;padding: 10px;top:-60px;left:480px" >
    <div class="bidTitle">请输入学生的学号以删除学生信息</div>
    <br/>
    <div style="height:180px;width:180px;margin:0px auto;" align="right">
    <p sytle="text-align:center;">
        <img src="css/02.png" width="160" height="160" align="right"/>
    </p>
    </div>
    <form action="delete_opt.php" method="post" class="logCon" >
        <input type="text" name="delete" class ="bt_input" placeholder="请输入要删除学生信息的学号">
        <br/>
        <input class="logingBut" type="submit" value="删除" style="width:330px;margin-left:-20px">
    </form>
    <div class="bidTitle">
        <p><a href="welcome_mag.html" align="center" >返回服务选择页面</a></p>
    </div>
</div>
</body>
</html>

delete_opt.php文件++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>删除操作后台执行页面</title>
</head>
<?php
function get_str($str){
    $val = ($_POST[$str])?$_POST[$str]:null;
    return $val;
}
$number = get_str("delete");

$con = mysqli_connect("localhost","root","");
if(!$con){
    ?>
    <script type="text/javascript">
        alert("数据库连接失败");
        window.location.href="delete.html";
    </script>
    <?php
}

$sql = "select * from stu_info where id=$number";
mysqli_select_db($con,"sgmsystem");
$info = mysqli_query($con,$sql);
$num = mysqli_num_rows($info);
if(!$num){
    ?>
    <script type="text/javascript">
        alert("找不到该同学,请重新输入学号");
        window.location.href="delete.html";
    </script>
<?php }
else{
//找到了该同学,进行删除操作
$sql = "delete from stu_info where id = $number";
$info = mysqli_query($con,$sql);
if($info){
    //删除成功
    ?>
    <script type="text/javascript">
        alert("删除成功");
        window.location.href="delete.html";
    </script>
    <?php
}
else{
//删除失败
?>
<script type="text/javascript">
    alert("删除失败");
    window.location.href="delete.html";
</script>
<?php
}
}
?>
版权声明:本文来源CSDN,感谢博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/jinHeee/article/details/90411197
站方申明:本站部分内容来自社区用户分享,若涉及侵权,请联系站方删除。
  • 发表于 2021-06-14 07:12:27
  • 阅读 ( 894 )
  • 分类:研发管理

0 条评论

请先 登录 后评论

官方社群

GO教程

猜你喜欢