【问题标题】:Error 310 (net::ERR_TOO_MANY_REDIRECTS): There were too many redirects. using php错误 310 (net::ERR_TOO_MANY_REDIRECTS):重定向太多。使用 php
【发布时间】:2013-11-10 04:12:15
【问题描述】:

这是我的索引页

  session_start();
if(!isset($_SESSION["manager"])){

    header("location:admin_login.php");
    exit();
}
#Be sure to chack that this manager SESSION value is in fact in the database
$managerID =preg_replace('#[0.9]#l','',$_SESSION['id']);//filter everything but numbers and letters 
$manager = preg_replace('#[A_Za_z0.9]#i','',$_SESSION["manager"]);//filter everything but numbers and letters
$password = preg_replace('#[A_Za_z0.9]#i','',$_SESSION["password"]);//filter everything but numbers and letters
//Run mySQL query to be sure that this person is an admin and that thier password session var equals the database informartion
//Connect to MYSQL database
include "../storescripts/connect_to_mysql.php";
$sql = mysql_query("SELECT * FROM `admin` WHERE id='$managerID' AND username='$manager' AND password='$password' LIMIT 1");//query the person
//........MAKE SURE PERSONE EXISTS IN DATABASE....
$existCount = mysql_num_rows($sql);//Count the row nums
if($existCount == 0){//evaluate the count
    header("location:../index.php");
    exit();
}

这是我的 admin_login 页面

   session_start();
if(!isset($_SESSION["manager"])){

    header("location:index.php");
    exit();
}

?>
<?php
#Palse the log in from if user has filled it out and pressed "Log In"
if(isset($_POST["username"])&&isset($_POST["password"])){

    $manager = preg_replace('#[A_Za_z0.9]#i','',$_POST["username"]);//filter everything but numbers and letters
    $password = preg_replace('#[A_Za_z0.9]#i','',$_POST["password"]);//filter everything but numbers and letters
    //connect to the MYSQL database
    include "../storescripts/connect_to_mysql.php";
    $sql = mysql_query("SELECT id FROM `admin` WHERE username='$manager' AND password='$password' LIMIT 1");//query the person
    //........MAKE SURE THE PERSONE EXISTS IN DATABASE....
    $existCount = mysql_num_rows($sql);//Count the row nums 
    if($existCount==1){//evaluate the count
        while($row=mysql_fetch_array($sql)){
            $id=$row['id'];
        }
        $_SESSION["id"]=$id;
        $_SESSION["manager"]=$manager;
        $_SESSION["password"]=$password;
        header("location:index.php");
        exit(); 
    } else {
        echo "That information is incorrect,try again<a href='index.php'>Click Here</a>";
        exit(); 
    }
}

我在谷歌浏览器上有错误:

清除此网站的 cookie 或允许第三方 cookie 可能会解决问题。如果不是,则可能是服务器配置问题,而不是您的计算机问题。

错误 310 (net::ERR_TOO_MANY_REDIRECTS):重定向过多。

【问题讨论】:

  • 据我所知,如果未设置$_SESSION["manager"],您会不断地从index.php 重定向到admin_login.php,反之亦然。

标签: php mysql sql session


【解决方案1】:

在 index 页面和 admin_login 页面中,都有 $_SESSION["manager"] 检查,因此如果没有设置 manager 索引,则这两个 URL 之间存在重定向循环。

您可能希望删除 admin_login 页面中的会话检查。

【讨论】:

    【解决方案2】:

    尝试var_dump($_SESSION);,要么设置不正确,要么会话未启动

    【讨论】:

      猜你喜欢
      • 2012-06-30
      • 2012-09-22
      • 2013-07-11
      • 2012-05-19
      • 2020-08-22
      • 2020-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多