SOLVED The problem was another aspect of the script refreshing the page to load a cookie. The Redirect command was lost in the process. Thanks to all who helped! ------------------------- if ( isset($_GET['Redirect']) && $_GET['Redirect'] = "1" ) { ?> <script language="JavaScript" type="text/javascript"> <!-- location.replace('<?php echo $PHP_SELF.'?ShowProducts=1&'.CART; ?>'); //--> </script> <?php } PHP: Basically, when a user visits "page.php?Redirect=1," I want the script to perform a redirect. In this configuration it NEVER works. In others, it redirects regardless of what "Redirect" is set to or if it even exists. Still other scenarios cast it into an infinite loop. I've tried switch statements, I've tried every possible combination of =, ==, quotes, no quotes, etc., and I've just about had it. Any suggestions? Thanks, Peter
hi, do you really need to have those js? maybe.. <? if(isset($_GET['Redirect'])): if($_GET['Redirect'] == 1) header('location: '.$_SERVER['PHP_SELF'].'?ShowProducts=1&'.CART); endif; ?>
Three things that I see wrong with the line: if ( isset($_GET['Redirect']) && $_GET['Redirect'] = "1" ) PHP: 1) You're assigning to your get parameter, not comparing. Use double equals. 2) You're comparing to a string, when I believe you really want to compare to a number. I may be wrong about that, but either way, get used to NOT putting quotes around numbers when you want to treat them as numbers. PHP normally deals with it, but will sometimes choke. 3) Order of operations: not sure, but maybe your && has a higher precedence than the comparison. Use brackets and force the order. So... I'd try something like: if ( isset($_GET['Redirect']) && ($_GET['Redirect'] == 1) ) PHP: instead.
Still no luck, guys... Does $_GET have to involve a form? I'm trying to achieve the aforementioned effect when Redirect=1 is added to the URL.
Try print_r($_GET); $_GET is all the variables passed from the URL - or at least, it should be. Sometimes, but rarely, configurations are different.
It doesn't require a form, no. So long as you use the same case, you should be fine. It wouldn't hurt to try dumping your GET variable and see what it says is there... try adding: print '<pre>'; print_r($_GET); print '</pre>'; to see what PHP thinks is in the GET.
Good idea. It shows an array, but for some reason Redirect isn't in there, even when I manually type it...