我有一个登录页面,允许用户输入电子邮件和密码后检查数据是否正确,浏览器必须显示配置文件页面,但问题是,我输入电子邮件和密码后,系统冻结,不显示配置文件页面,即使数据是真的。
,但如果我回一个消息,通知用户的数据是正确的浏览器显示此消息,谁能帮助我??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']);
请试试我的代码,谁告诉我哪里错了
<标题> login。<?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 h1> header。php h1> 的[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
标题>标题>[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
您的header.php脚本中有一个错误,导致系统退出。注意13行的last_name
,它不存在,我猜它与它有关。您不仅要在发送报头之前输出数据,甚至通知也应该固定:)
从header中删除localhost。应该是header("Location: profile.php");
我在header中找到了解决方案,您可以替换以下代码
header("Location: http://localhost/profile.php");
如果它不工作尝试下面-->
是否可以删除localhost,只保留header
中的/profile.php ?如果login.php和profile.php在同一个文件夹中,试试这个->
用header("Location: /profile.php");
代替header("Location: localhost/profile.php");
将header("Location: localhost/profile.php");
替换为header("Location: /<pathfromlogin.php>/profile.php");
,如header("Location: /info/user/profile.php");
问题是你在标题位置给出的URL像下面这样替换标题
header("Location: http://localhost/profile.php");