重定向循环问题

时间:2013-12-28 19:21:44

标签: php loops redirect

我有一个重定向问题,我不明白为什么..当我转到index.php时,它将重定向到members.php并返回等等。我希望注册用户无法看到index.php页面,所以我在页面上方添加了这段代码:

的index.php:

<? 
session_start();
$loggedin = $_SESSION['logged'];
if ($loggedin == 'TRUE') {

header ("Location: members.php");

} else {

$loggedin == 'FALSE';

}


?>

Logout.php

<?php 

session_start();
if (isset($_SESSION['username']))
{
unset($_SESSION['username']);
} 
header("location:index.php");
?>

Members.php:

 <?php 
 session_start();
 include_once"connect.php";
 if(!isset($_SESSION['username']) || !isset($_SESSION['password'])){
header("Location: index.php");
 }else{
  $fetch_users_data = mysql_fetch_object(mysql_query("SELECT * FROM `members` WHERE                           
  username='".$_SESSION['username']."'"));

 $query = mysql_query("SELECT * FROM `members` WHERE      
 username='".$_SESSION['username']."'");
 $count = mysql_num_rows($query); 
 $username = $count['0'];
 }

 $query = mysql_query("SELECT * FROM `members` WHERE      
 username='".$_SESSION['username']."'");
 $count = mysql_num_rows($query); 
 $username = $_SESSION['username'];

 ?>

1 个答案:

答案 0 :(得分:1)

试试这个: 在Logout.php中:

<?php 

session_start();
if (isset($_SESSION['username']))
{
unset($_SESSION['username']);
unset($_SESSION['logged']);
} 
header("location:index.php");
?>