此页面未正确重定向

[英]This page is not redirecting properly


I used the following script from about.com: http://php.about.com/od/finishedphp1/ss/php_login_code_2.htm

我使用了about.com上的以下脚本:http://php.about.com/od/finishedphp1/ss/php_login_code_2.htm

The problem is that a few times it gives me this error: The page isn't redirecting properly. Firefox has detected that the server is redirecting the request for this address in a way that will never complete. Code:

问题是它有几次给我这个错误:页面没有正确重定向。 Firefox检测到服务器正在以永远不会完成的方式重定向此地址的请求。码:

<?php

session_start(); 



// Process the POST variables
$username = $_SESSION["user_name"];
//$password = $_POST["password"];


    // Set up the session variables
     $_SESSION["user_name"] = $username;

       $ugh = $_REQUEST['url_name'];

          if($_POST){
           $_SESSION['user_name']=$_POST["user_name"];
          $_SESSION['password']=$_POST["password"];  
           }



              $secret = $info['password'];

            //Checks if there is a login cookie

            if(isset($_COOKIE['ID_my_site']))


             //if there is, it logs you in and directes you to the members page

                { 
           $username = $_COOKIE['ID_my_site']; 

            $pass = $_COOKIE['Key_my_site'];

    $check = mysql_query("SELECT user_name, password 
            FROM users WHERE user_name = '$username' 
            and url_name='$ugh'")or die(mysql_error());

          while($info = mysql_fetch_array( $check )) 



          {

               if (@ $info['password'] != $pass) 
                {

                    }

                  else

                 {

                  header("Location: home.php");



                  }

                     }

                     }


       //if the login form is submitted 

      if (isset($_POST['submit'])) { // if form has been submitted



         // makes sure they filled it in

             if(!$_POST['user_name'] | !$_POST['password']) {

    die('You did not fill in a required field.');

       }

// checks it against the database



if (!get_magic_quotes_gpc()) {

    $_POST['user_name'] = addslashes($_POST['user_name']);


}

$check = mysql_query("SELECT user_name,password 
    FROM users WHERE user_name = '".$_POST['user_name']."' 
    and url_name='".$ugh."'")or die(mysql_error());



         //Gives error if user dosen't exist

          $check2 = mysql_num_rows($check);

         if ($check2 == 0) {

           die('That user does not exist in our database. 
          <a href=add.php>Click Here to Register</a>');

            }

        while($info = mysql_fetch_array( $check ))  

            {

          $_POST['password'] = md5($_POST['password']);
          $_POST['password'] = $_POST['password'];



             //gives error if the password is wrong



           if (@ $_POST['password'] != $info['password']) {

            die('Incorrect password, please try again');


              }

              else 

             { 


          // if login is ok then we add a cookie 

         $_POST['user_name'] = stripslashes($_POST['user_name']); 

     $hour = time() + 3600; 

            setcookie(ID_my_site, $_POST['user_name'], $hour); 

            setcookie(Key_my_site, $_POST['password'], $hour);   



            //then redirect them to the members area 

           header("Location: home.php"); 

            } 

           } 

            } 

          else 

          {  



           // if they are not logged in 

           ?> 

2nd code:

Then on each member page i use the following to make sure their login is correct:

然后在每个成员页面上,我使用以下内容确保他们的登录正确:

      // Process the POST variables
       $email = $_SESSION["user_name"];


     // Set up the session variables
    $_SESSION["user_name"] = $username;


   if(!isset($_SESSION['user_name'])) { header("Location: log.php");}

2 个解决方案

#1


2  

To paraphrase Blowski: http://kb.mozillazine.org/The_page_is_not_redirecting_properly

用Blowski的话来解释:http://kb.mozillazine.org/The_page_is_not_redirecting_properly

It's like firefox has reached it's maximum recursion depth: it has detected a seemingly endless loop of redirects

这就像firefox达到了它的最大递归深度:它已经检测到看似无限的重定向循环

#2


1  

What's the name of the files in the above scripts? If the name of the first script is home.php, then when a user visits home.php, it will keep reloading if the password is incorrect, so Firefox will return that message.

上述脚本中文件的名称是什么?如果第一个脚本的名称是home.php,那么当用户访问home.php时,如果密码不正确,它将继续重新加载,因此Firefox将返回该消息。

Alternatively, do you have anything in your .htaccess which is causing it?

或者,你的.htaccess中有没有引起它的东西?

智能推荐

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:http://www.itdaan.com/blog/2011/04/24/33bf5e24a6e19e509a780e72cc97dd71.html



 
© 2014-2019 ITdaan.com 粤ICP备14056181号  

赞助商广告