0

我有一个登录页面,允许用户在检查数据是否正确后输入电子邮件和密码,浏览器必须显示个人资料页面,但问题是在我输入电子邮件和密码后系统冻结并且即使数据也不会显示个人资料页面是真的。

但是,如果我回显一条消息,通知用户数据正确,浏览器会显示此消息,谁能帮助我???PLZ我从2天到现在都试过了,没有任何成功,没有人给我正确的解决方案。

我弄清楚错误是什么,但我不知道如何解决它

 if($_SESSION['login'] != 'true'){
        **header("location:index.php");**
    }
    //var_dump($login_user);

   $login = ($_SESSION['login']);
   $id = ($_SESSION['user_id']);
   $login_user = ($_SESSION['username']);
   $firstname = ($_SESSION['first_name']);
   $lastname = ($_SESSION['last_name']);

请尝试我的代码,任何人都告诉我这是错误的

登录.php

<?php
session_start();
ob_start();
error_reporting(E_ALL);
require_once('include/connect.php');
$message = ""; 
if(!empty($_POST['email']))
{

$email = $_POST['email'];
$pass = $_POST['pass'];

$email = strip_tags($email);
$pass = strip_tags($pass);
$email = mysql_real_escape_string($email);
$pass = mysql_real_escape_string($pass);
//$pass = md5($pass);

$sql=mysql_query( "SELECT user_id, email_address, first_name 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)
  {
      $row = mysql_fetch_array($sql);

          $id = $row['user_id'];
          $_SESSION['user_id'] = $id;

          $firstname = $row['first_name'];
          $_SESSION['first_name']= $firstname;

          $email = $row['email_address'];
          $_SESSION['email_address']= $email;

          mysql_query("UPDATE user SET last_log_date=now() WHERE user_id='$id'");

        //$message = "correct email and passworddd!!";  
          header("Location: profile.php");
         // exit();   
  }//close if 
  else
  {
      $message = "incorrect Email or Password!!";
      //exit();
  }
}//close if
ob_end_flush();
?> 

配置文件.php

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


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

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

else
{
    print "Important  data  are missing";
    print_r($_SESSION);
    exit();

}

$sql = mysql_query("SELECT * FROM user  WHERE user_id='$id'") or die(mysql_error());
$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\">";
   }
   echo $id, $firstname, $birth_date;
?>

头文件.php

<?php
session_start();

if($_SESSION['login'] != 'true'){
        header("location:index.php");
    }
    //var_dump($login_user);

   $login = ($_SESSION['login']);
   $id = ($_SESSION['user_id']);
   $login_user = ($_SESSION['username']);
   $firstname = ($_SESSION['first_name']);
   $lastname = ($_SESSION['last_name']);

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href='http://fonts.googleapis.com/css?family=Oswald:400,300' rel='stylesheet' type='text/css' />
<link href='http://fonts.googleapis.com/css?family=Abel|Satisfy' rel='stylesheet' type='text/css' />
<link href="default.css" rel="stylesheet" type="text/css" media="all" />

</head>

<body>
<div id="banner">
  <div class="img-border">
    <div id="header-wrapper">
      <div id="header">

        <div id="logo">
          <marquee width="80%">
            <h1><b>Social Media Network</b></h1>
          </marquee>
        </div>
         <div id="menu">
             <ul>
                <li><a href="profile.php" accesskey="1" title=""><?php echo $login_user ?>'s Profile</a></li>
                <li><a href="update_account.php" accesskey="2" title="">Update</a></li>
                <li><a href="search.php" accesskey="3" title="">Search</a></li>
                <li><a href="map.php" accesskey="4" title="">Map</a></li>
                <li><a href="feedback_form.php" accesskey="4" title="">Feedback</a></li>
                <li><a href="help.php" accesskey="6" title="">Help</a></li>
                <li><a href="logout.php" accesskey="7" title="">Logout</a></li>
            </ul>
         </div>


      </div>
    </div>
    <img src="images/web_header copy.jpg" width="1121" height="210" alt="" />
  </div>
</div>

</body>
</html>

在 apache 错误日志中

[Wed May 08 08:19:12 2013] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://localhost/new%20adamKhoury/index.php
[Wed May 08 08:19:12 2013] [error] [client 127.0.0.1] PHP   1. {main}() C:\\wamp\\www\\new adamKhoury\\profile.php:0, referer: http://localhost/new%20adamKhoury/index.php
[Wed May 08 08:19:12 2013] [error] [client 127.0.0.1] PHP   2. require_once() C:\\wamp\\www\\new adamKhoury\\profile.php:181, referer: http://localhost/new%20adamKhoury/index.php
[Wed May 08 08:19:12 2013] [error] [client 127.0.0.1] PHP Notice:  Undefined index: last_name in C:\\wamp\\www\\new adamKhoury\\header.php on line 13, referer: http://localhost/new%20adamKhoury/index.php
[Wed May 08 08:19:12 2013] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://localhost/new%20adamKhoury/index.php
[Wed May 08 08:19:12 2013] [error] [client 127.0.0.1] PHP   1. {main}() C:\\wamp\\www\\new adamKhoury\\profile.php:0, referer: http://localhost/new%20adamKhoury/index.php
[Wed May 08 08:19:12 2013] [error] [client 127.0.0.1] PHP   2. require_once() C:\\wamp\\www\\new adamKhoury\\profile.php:181, referer: http://localhost/new%20adamKhoury/index.php
[Wed May 08 08:19:12 2013] [error] [client 127.0.0.1] File does not exist: C:/wamp/www/favicon.ico
4

4 回答 4

0

我在标题中得到了解决方案,您可以替换以下代码吗

header("Location: http://localhost/profile.php");

如果它不起作用,请尝试以下 -->

你可以删除 localhost 并将 /profile.php 保留在标题中吗

如果 login.php 和 profile.php 在同一个文件夹中试试这个 ->

替换header("Location: localhost/profile.php");header("Location: /profile.php");

别的

替换header("Location: localhost/profile.php");header("Location: /<pathfromlogin.php>/profile.php");ex。header("Location: /info/user/profile.php");

于 2013-05-08T12:26:49.367 回答
0

问题在于您在标题位置给出的 URL 替换您的标题,如下所示

 header("Location: http://localhost/profile.php");
于 2013-05-08T12:34:57.533 回答
0

从标头中删除 localhost。它应该像header("Location: profile.php");

于 2013-05-08T12:16:20.703 回答
0

您的 header.php 脚本中有一个错误导致您的系统退出。注意last_name第 13 行,它不存在,我猜它与它有关。您不仅要在发送标头之前输出数据,甚至还应修复通知 :)

于 2013-05-08T12:17:20.697 回答