php用户登录以及后台处理
来源:互联网 发布:unity3d 海底光影 编辑:程序博客网 时间:2024/05/22 06:34
一、用户登录界面
<html>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>学生综合评分系统</title>
<body>
<div id="formbackground" style="position:absolute; width:100%; height:100%; z-index:-2"><img src="1.png" height="100%" width="100%"/></div>
<body>
<form action="logincheck.php" method="post">
<div id=content style="position:absolute;">
<table align="center">
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
<tr>
<td>                                                                                                 用户名</td>
<td><input type="text" name="username" ></td>
</tr>
<tr>
<td>                                                                                                 密 码</td>
<td><input type="password" name="password" ></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="login_student" value="学生登录">   <input type="submit" name="login_teacher" value="教师登录"></td>
</tr>
</div>
</form>
<?php
?>
</body>
</html>
二、后台处理
<?php
session_start();
header("Content-Type:text/html;charset=gbk");
//isset检测变量是否被设置,最好使用上,可以不使用他的。
//学生登录
if(isset($_POST["login_student"]) && $_POST["login_student"] =="学生登录"){
$user = $_POST["username"];
$psw = $_POST["password"];
if($user == "" || $psw == ""){
//alert是警告的意思。这句的主要做用就是弹出警告,返回上一页。
echo "<script LANGUAGE='javascript'>alert('请输入用户名或密码!'); history.go(-1);</script>"; //弹出提示框返回上一
}else{
$con=mysql_connect("localhost","root","9277");
mysql_select_db("School",$con);
mysql_query("set names 'gbk'");
$result=mysql_query("select * from Student where Username ='$user' ");//mysql_query 查询数据库的函数
while($row=mysql_fetch_array($result)){
if($row[3]==""){//用户不存在
echo "<script LANGUAGE='javascript'>alert('user is not exit'); history.go(-1);</script>"; //弹出提示框返回上一页
}else if($row[4]!=$psw){
echo "<script LANGUAGE='javascript'>alert('password is wrong'); history.go(-1);</script>"; //弹出提示框返回上一页
}else{
$_SESSION["Student_Name"]=$row[1];//页面显示登录人的姓名。
$_SESSION["username"]=$row[3];
$_SESSION["Student_ID"]=$row[0];
$_SESSION["Student_Class"]=$row[2];
if($row[5]=="A"){
header("Location: http://192.168.116.128/school/studentA/exam/exam.php");//跳转到这个界面。
}else if($row[5]=="B"){
header("Location: http://192.168.116.128/school/studentB/exam/exam.php");//跳转到这个界面。
}else if($row[5]=="C"){
header("Location: http://192.168.116.128/school/studentC/exam/exam.php");//跳转到这个界面。
}
}
}
}
}
if(isset($_POST["login_teacher"]) && $_POST["login_teacher"] =="教师登录"){
$user = $_POST["username"];
$psw = $_POST["password"];
if($user == "" || $psw == ""){
//alert是警告的意思。这句的主要做用就是弹出警告,返回上一页。
echo "<script LANGUAGE='javascript'>alert('请输入用户名或密码!'); history.go(-1);</script>"; //弹出提示框返回上一
}else{
$con=mysql_connect("localhost","root","9277");
mysql_select_db("School",$con);
mysql_query("set names 'gbk'");
$result=mysql_query("select * from Teacher where Username ='$user' ");//mysql_query 查询数据库的函数
while($row=mysql_fetch_array($result)){
if($row[2]==""){
echo "<script LANGUAGE='javascript'>alert('user is not exit'); history.go(-1);</script>"; //弹出提示框返回上一页
}else if($row[3]!=$psw){
echo "<script LANGUAGE='javascript'>alert('password is wrong'); history.go(-1);</script>"; //弹出提示框返回上一页
}else{
$_SESSION["teacher_Name"]=$row[0];//页面显示登录教师的姓名。
$_SESSION["teacher_Class"]=$row[4];
header("Location: http://192.168.116.128/school/teacher/exam/exam.php");
}
}
}
}
?>
- php用户登录以及后台处理
- php用户登录
- php用户登录代码
- php mysql 用户登录
- php实现用户登录
- onethink 用户前台登录注册,以及后台可以控制用户权限(待更)
- sqlplus登录以及用户登录切换
- ajax简单的后台用户登录验证
- openfire 后台用户登录认证代码解析
- php 设置用户自动登录
- PHP用户登录功能实现
- PHP判断用户登录状态
- PHP大量用户登录解决方案
- PHP 用户注册与登录
- PHP案例实现用户登录
- PHP-用户登录注册接口
- PHP处理在线用户
- PHP处理在线用户
- JAVA程序设计(14.2)----- 图书馆管理系统 初步设计 界面篇
- XMPP服务器环境的搭建
- boost库中bind()和function()的使用方法
- Oracle数据库mybatis 插入空值时报错(with JdbcType OTHER)
- tomcat配置HTTPS
- php用户登录以及后台处理
- HTML 入门,30分钟入门教程.
- 数据库集群实施
- csu1030: 素数槽
- iOS Developer:真机测试
- 第三章 资源管理
- 快学Scala习题解答—第三章 数组相关操作
- my blog my life
- 关于形如--error LNK2005: xxx 已经在 msvcrtd.lib ( MSVCR90D.dll ) 中定义--的问题分析解决