0

好的,所以我刚刚解决了我的最后一个问题,我需要再次帮助......所以我修复了身份验证代码,但现在每次我登录我的个人资料时,它都说我没有登录我的网站。这是 access-denied.php 代码:

<title>Access Denied</title>
<link href="loginmodule.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Access Denied </h1>
<p align="center">&nbsp;</p>
<h4 align="center" class="err">Access Denied!<br />
  You do not have access to this resource.</h4>

这是我的 auth.php 代码:

//Start session
session_start();

//Check whether the session variable SESS_MEMBER_ID is present or not
if(!isset($_SESSION['email']) || ($_SESSION['password'])){
    header("location: access-denied.php");
    exit();
}

这是我的个人资料页面代码:

<?php session_start(); ?>
<?php include("inc/incfiles/loggedheader.php")?>
<?php
    require_once('auth.php');
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Member Index</title>
<link href="css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Welcome <? if(isset($_SESSION['SESS_fname'])){
    echo $_SESSION['SESS_fname'];
} ?></h1>
<a href="member-profile.php">My Profile</a> | <a href="logout.php">Logout</a>
<p>Welcome to your profile! </p>
</body>
</html>

为什么我无法登录我的个人资料?我对这种类型的 PHP 一无所知,我几乎还在学习,我的朋友(他正在帮助我建立我的网站)得到了代码,然后通过电子邮件将它们发送给我。

4

2 回答 2

0

这是问题所在:

if(!isset($_SESSION['email']) || !isset($_SESSION['password'])){
    ...
}
于 2013-12-17T19:46:56.077 回答
0

线路有问题

if(!isset($_SESSION['email']) || ($_SESSION['password'])){

您确实需要检查 if 条件的第二部分(密码检查)。在这里,您正在检查会话中是否存在电子邮件或密码是否存在于会话中。因此,即使由于第二个条件而设置了电子邮件然后页面 goto 访问被拒绝也是如此。如有必要,您应该使用

if(!isset($_SESSION['email']) || !($_SESSION['password'])){
于 2013-03-24T04:59:37.263 回答