我进行了login.php
设置,以便每当登录成功时,它都会自动定向到profile.php
. 但是,即使登录成功,每次我去它profile.php
时仍然说“您必须登录才能访问此页面”。为什么?
这是我的login.php
:
$email = $_POST['email-field'];
$password = $_POST['password-field'];
if ($email && $password)
{
$connect = mysql_connect("xx", "xx", "xx") or die("Couldnt connect!");
mysql_select_db(xx) or die("Couldnt find db");
$query = mysql_query("SELECT * FROM users WHERE email = '$email'");
$numrows = mysql_num_rows($query);
if ($numrows != 0)
{
while ($row = mysql_fetch_assoc($query))
{
$email = $row['email'];
$md5password = $row['password'];
}
if ($email == $email && $md5password == md5($password))
{
header("Location: profile.php");
$_SESSION['email']==$email;
}
else
echo "Incorrect password";
}
else
die("That user doessnt exist!");
}
else
die("Please enter a username and a password");
我的profile.php
:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php
include('get-info.php');
session_start();
if ($_SESSION['email'])
echo "<a href=logout.php>Logout</a>";
else
die("You must be logged in to access this page");
?>
<html>
<head>
<title>
R-A | Profile
</title>
<link href='css.css' rel='stylesheet' type='text/css' />
</head>
<body class='body3' >
<div class='logo-bar'>
<div class='menu'>
<img src='images/rateaway.png' class='logo-bar-img' />
<div class='menu-options'>
<a href='index.php' class='menu-links' >Home</a>
<a href='profile.php' class='menu-links' >Profile</a>
<a href='profile.php' class='menu-links' >Friends</a>
</div>
</div>
</div>
<div class='profile-main-content' >
<div class='profile-current-info'>
<p class='profile-name'> <?php get_info('iran_mateu@yahoo.com', 'name'); ?> </p>
<img src='<?php get_info('iran_mateu@yahoo.com', 'profilepic'); ?>' class='profile-pic'/>
<p class='profile-dob' > Born: <?php get_info('iran_mateu@yahoo.com', 'dob'); ?> </p>
<p class='profile-country' > Currently lives in: <?php get_info('iran_mateu@yahoo.com', 'country'); ?> </p>
<p class='profile-gender' > Gender: <?php get_info('iran_mateu@yahoo.com', 'gender'); ?> </p>
</div>
<div class='profile-edit-info' >
</div>
</div>
</body>