データが正しいかどうかを確認した後、ユーザーが電子メールとパスワードを入力できるログイン ページがあります。ブラウザはプロファイル ページを表示する必要がありますが、問題は、電子メールとパスワードを入力した後、システムがフリーズし、データ真です。
しかし、データが正しいことをユーザーに通知するメッセージをエコーすると、ブラウザーはこのメッセージを表示し、誰でも私を助けることができますか??? 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
<?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