Home >php教程 >php手册 >PHP学习笔记-SESSION的使用

PHP学习笔记-SESSION的使用

WBOY
WBOYOriginal
2016-06-21 09:05:51837browse

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 从结果集中取得一行作为关联数组,或数字数组,或二者兼有




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:一个邮件解码类Next article:做Excel数据简单的范例