2013-05-08 108 views
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']); 

PLZ尽我的代码和任何人告诉我它是什么wrongg

的login.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(); 
?> 

profile.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; 
?> 

的header.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 
+3

不要放弃'在标题位置localhost'。并在头重定向后保持'退出'。 – Rikesh 2013-05-08 12:13:14

+0

检查你的错误在文件的顶部添加'ini_set(“display_errors”,1);''。 – Rikesh 2013-05-08 12:15:17

+0

@Rikesh,'display_errors'没有被'ini_set'设置。它应该在'php.ini'中设置 – Amir 2013-05-08 12:17:51

回答

0

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

+0

编辑我的问题,我将添加标题.php – user2360853 2013-05-08 12:29:49

+0

header.php中没有会话开始,所以你在路上失去了会话? – ChrisH 2013-05-08 12:33:33

+0

我确实在header中添加了session_start(),但仍然没有工作 – user2360853 2013-05-08 12:41:33

0
删除

本地主机。它应该像header("Location: profile.php");

+2

或使用完整的URL,如http:// localhost /。目前的方式('header(“Location:localhost/profile.php”);')被处理为一个目录可能 – ChrisH 2013-05-08 12:18:28

+0

哦对不起,它一定是一个错误,因为头没有本地主机 – user2360853 2013-05-08 12:27:48

0

我在标题为这个解决方案可以在更换下面的代码

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

如果它不会工作尝试下面 - >

可以删除本地主机,只是不停/profile.php在头

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

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

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

header("Location: /<pathfromlogin.php>/profile.php");前更换header("Location: localhost/profile.php");header("Location: /info/user/profile.php");

0

问题是与你的头位置 给定的URL替换你的头象下面

header("Location: http://localhost/profile.php"); 
相关问题