help..............php页面出现源代码,如何解决
总共涉及三个页面第一个页面 登陆页面
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网络在线考试系统</title>
</head>
<body>
<form name="form1" method="post" action="checkuser.php">
<table width="240" height="107" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#2d6da5">
<tr>
<td height="23" colspan="2" > <div align="center" > 网络在线考试系统</div></td>
</tr>
<tr>
<td width="96" height="23"> <div align="right">用户类别: </div></td>
<td width="138"> <select size="1" name="userkind">
<option selected>学生</option>
<option>教师</option>
<option>管理员</option>
</select></td>
</tr>
<tr>
<td height="18"> <div align="right">用户名:</div></td>
<td><input type="text" name="userid" size="13" ></td>
</tr>
<tr>
<td height="18"> <div align="right">密 码</div></td>
<td><input type="password" name="pwd" size="13" ></td>
</tr>
<tr>
<td height="23" colspan="2"><div align="center">
<input type="submit" value="登 录" name="B1" >
</div></td>
</tr>
</table>
</form>
</body>
</html>
它的效果如下所示
第二个页面 连接数据库,很简单一个页面conn.php
<?
$host="localhost";
$user="root";
$passwd="";
$db="exam_db";
$conn=mysql_connect($host,$user,$passwd) or die("连接MYSQL服务器失败");
mysql_selectdb($db);
mysql_query("set names 'gbk'");
?>
第三个页面 检查用户登录页面 checkuser.php
<?
session_start();
require("conn.php");
$sql="select * from teachuser where t_userid='admin'";
$rs=mysql_query($sql,$conn) or die("查询失败");
if (mysql_num_rows($rs)==0) {
$sql="insert into teachuser (t_userid,t_username,t_pwd,t_usertype)
values('admin','管理员',PASSWORD('admin'),'管理员')";
mysql_query($sql) or die("插入记录失败");
}
if (! isset($_SESSION['name'])) {
if (isset($_REQUEST['userid'])) {
$userid = $_REQUEST['userid'];
$pwd = $_REQUEST['pwd'];
if ($_REQUEST["userkind"]=="学生") {
$sql="select * from student_user,class where s_xh= '$userid' and s_pwd= password('$pwd') and s_class_id=class.class_id";
$result=mysql_query($sql,$conn) or die("执行SQL错误:$sql");
if (mysql_num_rows($result)==1) {
$row=mysql_fetch_array($result);
$_SESSION['xh']=$row['s_xh'];
$_SESSION['name']=$row['s_name'];
$_SESSION['class_id'] =$row['s_class_id'];
$_SESSION['classname'] =$row['classname'];
$_SESSION['photo']=$row['s_photo'];
header("Location:./exam/index.php");
} else {
include "login.php";
exit;
}
}else{ //教师和管理员
$sql="select * from teachuser where t_userid ='$userid' and t_pwd = password('$pwd')";
$result=mysql_query($sql,$conn);
if (mysql_num_rows($result)>0) {
$row=mysql_fetch_array($result);
$_SESSION['t_userid']=$row['t_userid'];
$_SESSION['name']=$row['t_username'];
$_SESSION['usertype'] =$row['t_usertype'];
header("Location:./admin/index.php");
}else {
include "login.php";
exit;
}
}
} else {
include "login.php";
exit;
}
}else {
echo $_SESSION['name'].",欢迎你回来。请刷新页面<br>";
exit;
}
?>
但无论输入正确的用户名或者密码都出现这样的如下的页面,请问这是什么问题?求高手解答,在线等。。。。急