- 论坛徽章:
- 0
|
session跨页传递的问题
thanks;
又有新的问题了,
Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in D:\usr\Apache\Apache2\htdocs\login.php on line 21
login.php
<?
session_start();
session_register(student_name);
session_register(teacher_id);
session_register(student_id);
?>
<?php
//set server access varables
$host = "localhost";
$user = "root";
$pass = "";
$db = "bylw";
$connection = mysql_connect($host, $user, $pass);
mysql_query("SET NAMES 'GBK'");
mysql_select_db($db) or die ("unable to connect !");
$user_id=$_POST['username'];
$password=$_POST['password'];
$exec= "select * from login where user_id=.$user_id. and password=.$password.";
$result=mysql_query($exec);
$rs=mysql_fetch_object($result);
$username=$rs->username;
if($rs->password==$password and $rs->pd=='teaher')
{
$teacher_name=$username;
$teacher_id=$user_id;
header ("Location: jiaoshi.htm");
}
elseif ($rs->password==$password and $rs->pd=='student')
{
$student_name=$username;
$student_id=$user_id;
header ("Location:student.htm");
}
else
{
echo "<script>alert('用户名或密码错误!');location.href='index.php';</script>";
}
?> |
|