Forum Moderators: coopster

Message Too Old, No Replies

Problem with Redirection Limit

I'm so lost!

         

ahmedtheking

10:43 pm on Jan 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I got this error:

"Redirection limit for this URL exceeded. Unable to load the requested page. This may be caused by cookies that are blocked"

What i did was make a HTML form that uses PHP_SELF to validate itself before it goes onto the next stage.

I used the var $error. If an error is picked up, it would display that error (nothing wrong with this...)

But it there isnt an error, I asked it to do the following:

if (!$error) {
$querystring = explode ('process=',$_SERVER['QUERY_STRING']);
$newquerystring = $querystring[1] + 1;
header ("Location: [".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']."?".$querystring[0]."process=".$newquerystring."");...]
}

where $querystring = "table=packages&package=intermediate&get=signup&process=2" and so on, ie, the header location should be:

http:// myserverthingy.watever/thefile.php?table=packages&package=intermediate&get=signup&process=3

(A space after http:// was purposely added)

Any got any suggestions?

ergophobe

12:19 am on Jan 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is this with Mozilla or Firefox? It seems to be a problem that arises with a header() and Moz/FF.

If you echo the Location string and then put that into your browser address bar, do you get a valid page?

ahmedtheking

2:07 am on Jan 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, i have FF!

Yes, i get a valid page, well its an error page that i made, but its a valid one!

It's only when I'm trying to move these values from the form that i am validating into the next area!

Any ideas on how i cud overcome this?

Is my method the right one to use?

grandpa

2:17 am on Jan 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I ran into this problem when a redirect was caught in a loop, continously sending the page until the limit was reached. It wasn't the sort of error that was spotted with simple error checking, as there wasn't an error in the code, per se.

You might try looking for that sort of thing, or comment your code one line at a time until the problem stops.

Hope that helps some...

ahmedtheking

2:36 am on Jan 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



What would you recommend I look for?

Here is my validation code:

// validate the data
if ($validate) {
// validate email
//print_r ("$Email, $Vemail");
//exit();
if (eregi("^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$", $Email)) { }
else { $error = "Email"; }
if ($Email!= "$Vemail") {
$error = "Vemail";
}
// validate postcode
function cleanupPostCode ($PostCode) {
$PostCode = strtoupper($PostCode);
$PostCode = ereg_replace('[[:punct:]]', ' ', $PostCode);
$PostCode = ereg_replace('[[:space:]]+', ' ', $PostCode);
$PostCode = str_replace(' O',' 0', $PostCode);
if ($PostCode{0} == '0') $PostCode{0} = 'O';
if ($PostCode{1} == '0') $PostCode{1} = 'O';
return $PostCode;
}

$PostCode = cleanupPostCode($PostCode);

if(eregi('^(([A-Z][A-Z]?)([1-9]*[0-9A-HJ-RT-Y]?))¦(BFPO)?(([0-9]{1}[ABD-HJLNP-UW-Z]{1,2})¦([0-9]{2}))$', $PostCode)) { }
else { $error = "PostCode"; }
// validate password
if (preg_match("/^[a-z0-9]{4,12}$/i",$Password)) { }
else { $error = "Password"; }
if ($Password!= "$VPassword") {
$error = "VPassword";
}
// validate domain
if (preg_match('#^http\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $domain)) { }
else { $error = "domain";}
// end validation

if ($error) {
print("$error");
exit();
}
}

And the header code is posted above. I don't get this loop thing, why is it looping itself?

ahmedtheking

2:39 am on Jan 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh no! Ive found out why!

I ask the form to pass a var called $validate so that the form can be validated. Once it is, the header reloads it, but because i used $_SERVER['QUERY_STRING'], the $validate var stays!

Is there a way to strip this var out of the $_SERVER['QUERY_STRING']?

ergophobe

6:54 pm on Jan 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Sure, youcan get rid of it with a regular expression.

Tell us what $_SERVER['QUERY_STRING'] looks like and how would you like it to look and we'll come up with the reg ex for you.

ahmedtheking

11:44 pm on Jan 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Oh no, it's all good! I don't want to put you through that much bother! but thanks anyway! I just asked the script to echo the location to where i wanted it to go. All the urls are standardised within my system, so i can go about updatin stuff, file names, etc... but the script will change all that for me!

Thanks for all the help! I'm gonna try and help someone onday! :D