gmc1103 Posted February 10, 2015 Share Posted February 10, 2015 Hi I'm having a problem with this error This is my code <?PHP error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin()) { $fgmembersite->RedirectToURL("index.php"); exit; } if($fgmembersite->UserId() == 1261){ $fgmembersite->RedirectToURL("testes.php"); exit; } $userid = $fgmembersite->UserId(); ?> And the result is a lot of testes.php until i get that error my chrome debug gives me this Request URL: http://testes.php Request Headers Provisional headers are shown Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.111 Safari/537.36 Any help Quote Link to comment https://forums.phpfreaks.com/topic/294500-too-many-redirects-error-in-php/ Share on other sites More sharing options...
raphael75 Posted February 10, 2015 Share Posted February 10, 2015 Just a guess, but is this code on the index.php page? If so, is there a condition that could cause the CheckLogin function to fail on that page? If so, it could set up an infinite loop where the index.php is redirecting back to itself. Quote Link to comment https://forums.phpfreaks.com/topic/294500-too-many-redirects-error-in-php/#findComment-1505364 Share on other sites More sharing options...
Werezwolf Posted February 11, 2015 Share Posted February 11, 2015 (edited) Just a suggestion You may want to send the userid after authentication to $_SESSION and have a script like this on your testes.php http://php.net/manual/en/reserved.variables.session.php <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); if(!session_id()){session_start();} require_once("./include/membersite_config.php"); if($_SESSION['userid'] != 1261){die(header('refresh:0; ../index.php', false));} //Do not pass Go, Do not collect $200 if userid is not equal to 1261 //Insert more code ?> Edited February 11, 2015 by Werezwolf Quote Link to comment https://forums.phpfreaks.com/topic/294500-too-many-redirects-error-in-php/#findComment-1505412 Share on other sites More sharing options...
Tom10 Posted February 12, 2015 Share Posted February 12, 2015 (edited) <?php error_reporting(E_ALL | E_NOTICE); ini_set('display_errors', '1'); require_once("./include/membersite_config.php"); if(!$fgmembersite->CheckLogin()) { $redir_index = "<meta http-equiv='refresh' content='0;index.php'>"; $fgmembersite->$redir_index(); exit; } if($fgmembersite->UserId() == 1261){ $redir_test = "<meta http-equiv'refresh' content='0;testes.php'>"; $fgmembersite->$redir_test(); exit; } $userid = $fgmembersite->UserId(); ?> Try this Edited February 12, 2015 by Tom10 Quote Link to comment https://forums.phpfreaks.com/topic/294500-too-many-redirects-error-in-php/#findComment-1505547 Share on other sites More sharing options...
brotherZ Posted February 12, 2015 Share Posted February 12, 2015 You are redirecting to the same page. I would remove the: if($fgmembersite->UserId() == 1261){ $fgmembersite->RedirectToURL("testes.php"); exit; } because you don't need to do this since you are already in the file. You can just add your extra code in the same file to do what you want to do. No redirect needed. Quote Link to comment https://forums.phpfreaks.com/topic/294500-too-many-redirects-error-in-php/#findComment-1505550 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.