页面展示:
主要代码:
登录:
<?php
if(isset($_POST['sub'])){ //检测变量是否设置,判断post过来的数据是否被提交过来
$uname=@$_POST['uname']; //获取用户输入的用户名
$upwd=@$_POST['upwd']; //获取用户输入的密码
//判断用户输入是否为空
if($uname==""||$upwd==""){
echo "<script>alert('请输入用户名或密码!');</script>";
}
else{
session_start(); //开启session
$_SESSION['uname']=$uname; //使用session变量传值
$_SESSION['upwd']=$upwd; //使用session变量传值
header("location:login_show.php"); //页面跳转
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>河南中医药大学课程查询系统</title>
<meta charset="utf-8">
<style type="text/css">
body{
cellpadding:0;
cellspacing:0;
margin:0;
pading:0;
background-color: #CCFFCC;
}
#con
{
padding :0;
margin:0;
width:1364px;
height:600px;
background-image:url(./images/beijing.png);
background-repeat :no-repeat ;
background-position :center ;
background-color :#CCFFCC;
}
table{
position:relative;
top:250px;
margin:auto;
width:300px;
}
.txt
{
width:220px;
height:30px;
margin-bottom:10px;
border:1px solid green;
text-align :left;
line-height :30px;
font-size:18px;
color :Black ;
}
.btn
{
width :70px;
height :30px;
}
#btn1{
margin-left:70px;
margin-right:20px;
}
a{
margin-left:20px;
font-size:14px;
color:green;
text-decoration: none;
}
a:hover{
color:#CCCCCC;
}
</style>
</head>
<body>
<div id="con">
<form action="login.php" method="post">
<table>
<tr>
<td>用户名:</td>
<td><input type="text" name="uname" class="txt"></td>
</tr>
<tr>
<td>密   码:</td>
<td><input type="text" name="upwd" class="txt"></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" name="sub" value="登录" class="btn" id="btn1">
<input type="reset" name="ret" value="重置" class="btn">
<a href="login_zhuce.php">注册</a>
</td>
</tr>
</table>
</form>
</div>
</body>
</html>
注册:
<?php
if(isset($_POST['sub'])){ //检测变量是否设置,判断post过来的数据是否被提交过来
$uname=@$_POST['uname']; //获取用户输入的用户名
$name=@$_POST['name'];
$usex=@$_POST['sex'];
$ubir=@$_POST['ubir'];
$uclass=@$_POST['uclass'];
$upwd=@$_POST['upwd']; //获取用户输入的密码
//判断用户输入是否为空
if($uname==""||$upwd==""){
echo "<script>alert('请输入学号或密码!');</script>";
}
else{
$conn=@mysql_connect('localhost:3307','root','') or die('连接失败');//建立与数据库的连接
mysql_select_db('kccxxt',$conn) or die('选择数据库失败'); //选择数据库
mysql_query("SET NAMES utf8");//设置字符集
$s_sql="select * from user where uid='$uname' and upwd='$upwd'";//sql查询语句
$s_result=@mysql_query($s_sql) or die('执行查询失败'); //执行SQL语句
$s_row=@mysql_fetch_array($s_result);//从返回的结果集中获取数据
//判断数据表中是否有该条数据,即判断该用户是否已被注册
if($s_row){
echo "<script>alert('该用户已存在&#x