Home > Backend Development > PHP Tutorial > 为何用session传值为空

为何用session传值为空

WBOY
Release: 2016-06-13 11:26:44
Original
879 people have browsed it

为什么用session传值为空?
member_login_do.php


  /* 会员登陆处理页 */
 require_once("../conn/Conn_DB.php");   //包含数据库链接文件
 if( $_POST["txt_username"]!= "" && $_POST["txt_pwd"]!= "" )
 {
   $name = $_POST["txt_username"];   //获取提交的用户名
   $pwd = $_POST["txt_pwd"];         //获取提交的密码
   $str = "select * from Member_Info where M_Name = '$name' and M_Password = '$pwd'"; //查询语句
   $result = mysql_query($str);      //执行SQL语句
   if( mysql_num_rows($result) >0 )  //查看返回的查询结果行数
   {
 session_id(SID);
         session_start();                //登陆成功,设置SESSION值
 $_SESSION['member'] = $_POST['txt_username'];    
 //session_write_close();
     echo "<script> window.location.href='../member_info.php';</script>";
 //exit(0);
   }
   else
   {
     echo "<script>alert('用户名或密码错误!');window.location.href='../member_login.php'</script>";
   }
 }
 else 
 {
   echo "<script>alert('请输入用户名和密码!');window.location.href='../member_login.php'</script>";
 }
 ?>
 

session MySQL php
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template