session|笔记
登陆页:
处理页:
require_once("conn.php");
SESSION_START();
$username=$_POST['username'];
$password=$_POST['password'];
$exec="select * from admin where username='".$username."'";
if ($result=mysql_query($exec)){
if ($rs=mysql_fetch_object($result)){
if($rs->password==$password){
$_SESSION['adminname']=$username;
echo "SESSION是".$_SESSION['adminname'];
}else{
echo "<script>alert('Password Check Error!');location.href('login.htm');</script>";
}
}else{
echo "<script>alert('Username Check Error!');location.href('login.htm');</script>";
}
}else{
echo "<script>alert('Database connection Error!');location.href=('login.htm');</script>";
}
?>
数据库驱动;
$conn = mysql_connect("127.0.0.1","root","");
mysql_select_db("temp",$conn);
?>
摘要:这次主要遇到以下问题:
Session保存路径设置有误,在php.ini文件中设置:session.save_path = D:\usr\local\php\sessiondata,要保证有此目录,
(2004-10-25 11:08:02) 三角猫(50494427)
你在操作数据库的时候, 尽量不要用 mysql_fetch_object 从结果集中取得一行作为对象
(2004-10-25 11:08:58) 三角猫(50494427)
用:mysql_fetch_row 从结果集中取得一行作为枚举数组
mysql_fetch_array 从结果集中取得一行作为关联数组,或数字数组,或二者兼有