php代码实现成绩查询的方法:1、创建前端登录页面代码;2、通过“if (isset($_SESSION[‘username’])) {…}”语法实现判断用户是否登录;3、创建后端管理登录页面;4、连接数据库;5、通过“session_start(); if (isset($_COOKIE[‘username’])) {$_SESSION[”]}”代码实现查询成绩即可。
本教程操作环境:Windows7系统、PHP8.1版、Dell G3电脑。
php代码怎么实现成绩查询?
PHP成绩查询系统
一个非常简陋的PHP成绩查询系统,期末作业。
立即学习“PHP免费学习笔记(深入)”;
因为上课打酱油了,所以这也是最后几天捣鼓出来的,代码都是东拼西凑的,只有简单的增删改查功能。就酱紫。
数据库:
一共这么几个文件(html、css、php都写一块了)
然后界面:(就长这样)
代码是按上图的文件顺序排的
nbsp;html>Document * { margin: 0px; padding: auto; } fieldset { margin: auto; margin-top: 200px; width: 400px; text-align: center; } ul li { margin: 0; padding: 0; } form { margin: 40px 30px 0; } form li { list-style: none; padding: 5px 0; } .login_btn { border: none; background: #01A4F1; color: #fff; font-size: 14px; font-weight: bold; height: 28px; line-height: 28px; padding: 0 10px; cursor: pointer; } a:link { text-decoration: none; color: blue; } a:visited { color: blue; text-decoration: none; } .return_but { float: right; }
登录后复制登录后复制登录后复制 0) { echo ” alert('添加成功'); location.href='show_teacher.php';”; } } } else { //缓存意外被清除后、 echo “用户信息丢失,3秒后返回登陆界面”; header(‘refresh: 3; url=index.php’); } ?>
nbsp;html>Document * { margin: 0px; padding: auto; } fieldset { margin: auto; margin-top: 200px; width: 400px; text-align: center; } ul li { margin: 0; padding: 0; } form { margin: 40px 30px 0; } form li { list-style: none; padding: 5px 0; } .login_btn { border: none; background: #01A4F1; color: #fff; font-size: 14px; font-weight: bold; height: 28px; line-height: 28px; padding: 0 10px; cursor: pointer; } a:link { text-decoration: none; color: blue; } a:visited { color: blue; text-decoration: none; } .return_but { float: right; }
登录后复制登录后复制登录后复制 0) { echo ” alert('添加成功'); location.href='show_teacher.php';”; } } } else { //缓存意外被清除后、 echo “用户信息丢失,3秒后返回登陆界面”; header(‘refresh: 3; url=index.php’); } ?>
nbsp;html>Document * { margin: 0px; padding: auto; } fieldset { margin: auto; margin-top: 200px; width: 400px; text-align: center; } ul li { margin: 0; padding: 0; } form { margin: 40px 30px 0; } form li { list-style: none; padding: 5px 0; } .login_btn { border: none; background: #01A4F1; color: #fff; font-size: 14px; font-weight: bold; height: 28px; line-height: 28px; padding: 0 10px; cursor: pointer; } a:link { text-decoration: none; color: blue; } a:visited { color: blue; text-decoration: none; } .return_but { float: right; }
登录后复制登录后复制登录后复制 0) { echo ” alert('修改成功'); location.href='show_teacher.php';”; } } } else { //缓存意外被清除后、 echo “用户信息丢失,3秒后返回登陆界面”; header(‘refresh: 3; url=index.php’); } ?>
nbsp;html>Document
登录后复制
nbsp;html>Document 0) { echo " alert('删除成功'); location.href='show_teacher.php';"; } } } else { //缓存意外被清除后、 echo "用户信息丢失,3秒后返回登陆界面"; header('refresh: 3; url=index.php'); } ?>
登录后复制
nbsp;html> * { margin: 0px; padding: auto; } fieldset { margin: auto; margin-top: 200px; width: 400px; text-align: center; } ul li { margin: 0; padding: 0; } form { margin: 40px 30px 0; } form li { list-style: none; padding: 5px 0; } .login_btn { border: none; background: #01A4F1; color: #fff; font-size: 14px; font-weight: bold; height: 28px; line-height: 28px; padding: 0 10px; cursor: pointer; }
登录后复制
nbsp;html>Document a:link { text-decoration: none; color: blue; } a:visited { color: blue; text-decoration: none; } <?php header("Content-Type:text/html;charset=utf-8"); session_start(); //清除session $username = $_SESSION['username']; $_SESSION = array(); session_destroy(); //清除cookie setcookie("username", '', time() - 1); setcookie("code", '', time() - 1); echo "点击重新登录"; header('refresh: 5; url=index.php'); echo "
5秒钟后自动返回到主页"; ?>
登录后复制
nbsp;html>Document * { margin: 0px; padding: auto; } a:link { text-decoration: none; color: blue; } a:visited { color: blue; text-decoration: none; } #box { margin: auto; margin-top: 200px; width: 800px; text-align: center; } table { width: 700px; padding: 0; margin: 0 auto; } td { border-right: 1px solid #C1DAD7; border-bottom: 1px solid #C1DAD7; font-size: 11px; padding: 6px 6px 6px 12px; color: #4f6b72; } tr:hover { background-color: #B0C4DE; } th { font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; color: #4f6b72; border-right: 1px solid #C1DAD7; border-bottom: 1px solid #C1DAD7; border-top: 1px solid #C1DAD7; letter-spacing: 2px; text-transform: uppercase; text-align: center; padding: 6px 6px 6px 12px; background: #CAE8EA no-repeat; }<?php header("Content-Type:text/html;charset=utf-8"); session_start(); //首先判断Cookie是否有记住用户信息 if (isset($_COOKIE['username'])) { $_SESSION['username'] = $_COOKIE['username']; $_SESSION['islogin'] = 1; } if (isset($_SESSION['islogin'])) { //已经登录 echo "成绩查询中心!
你的学号:" . $_SESSION['username'] . " "; echo "注销"; } else { //为登录 echo "你还未登录,请登录"; } ?> query($sql); //传值 while ($attr = $r->fetch_row()) { echo " "; } ?>
语文 数学 英语 综合 {$attr[1]} {$attr[2]} {$attr[3]} {$attr[4]}
登录后复制
nbsp;html>Document a:link { text-decoration: none; color: blue; } a:visited { color: blue; text-decoration: none; } * { margin: 0px; padding: auto; } #box { margin: auto; margin-top: 200px; width: 800px; text-align: center; } table { width: 700px; padding: 0; margin: 20px auto; } td { border-right: 1px solid #C1DAD7; border-bottom: 1px solid #C1DAD7; font-size: 11px; padding: 6px 6px 6px 12px; color: #4f6b72; } tr:hover { background-color: #B0C4DE; } th { font: bold 11px "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif; color: #4f6b72; border-right: 1px solid #C1DAD7; border-bottom: 1px solid #C1DAD7; border-top: 1px solid #C1DAD7; letter-spacing: 2px; text-transform: uppercase; text-align: center; padding: 6px 6px 6px 12px; background: #CAE8EA no-repeat; } .login_btn { border: none; background: #01A4F1; color: #fff; font-size: 14px; font-weight: bold; height: 28px; line-height: 28px; padding: 0 10px; cursor: pointer; }<?php header("Content-Type:text/html;charset=utf-8"); session_start(); //首先判断Cookie是否有记住用户信息 if (isset($_COOKIE['username'])) { $_SESSION['username'] = $_COOKIE['username']; $_SESSION['islogin'] = 1; } if (isset($_SESSION['islogin'])) { //已经登录 echo "成绩查询中心!
工号:" . $_SESSION['username'] . " "; echo "注销"; } else { //为登录 echo "你还未登录,请登录"; } ?> query($sql); //传值 while ($attr = $r->fetch_row()) { echo " "; } ?>
学号 语文 数学 英语 综合 操作 {$attr[0]} {$attr[1]} {$attr[2]} {$attr[3]} {$attr[4]} 修改 删除
登录后复制
推荐学习:《PHP视频教程》
以上就是php代码怎么实现成绩查询的详细内容,更多请关注【创想鸟】其它相关文章!
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至253000106@qq.com举报,一经查实,本站将立刻删除。
发布者:PHP中文网,转转请注明出处:https://www.chuangxiangniao.com/p/2074787.html