会话ID无法正常工作

时间:2013-05-07 22:12:06

标签: php mysql session

我有一个个人资料页面,但我得到会话ID错误我怎么能解决这个问题?  如果我提交登录过程,浏览器会显示错误消息:缺少重要数据

如何修复此错误??? 在登录页面中我做了:

$sql=mysql_query( "SELECT id FROM user WHERE email_address='$email'AND password='$pass'LIMIT 1") or die("error in user table");
$login_check = mysql_num_rows($sql);

  if($login_check > 0)
  {
      while($row = mysql_fetch_array($sql))
      {
          $id = $row['id'];
          $_SESSION['id']= $id;

个人资料页面

<?php
session_start();
 require_once('include/connect.php'); 


if(isset($_GET['id']))
{
    $id=$_GET['id'];
    var_dump($id);

}
elseif(isset($_SESSION['id']))
{
    $id= $_SESSION['id'];
}

else
{
    print "Important  data  are missing";
    //exit();

}

$sql = mysql_query("SELECT * FROM user  WHERE id='$id'") or die(mysql_error());
while($row = mysql_fetch_array($sql))
{
   $firstname=$row['first_name'];
   $lastname=$row['last_name'];
   $birth_date=$row['birth_date'];
   $registered_date=$row['registered_date'];
   //***************for upload img*****************//
   $check_pic="members/$id/image01.jpg";
   $default_pic="members/0/image01.jpg";
   if(file_exists($check_pic))
   {
       $user_pic="<img src=\"$check_pic\"width=\"100px\"/>";
   }
   else
   {
       $user_pic="<img src=\"$default_pic\">";
   }
}
?>

1 个答案:

答案 0 :(得分:0)

您的登录页面错过了脚本顶部的session_start()