• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

Redir not going to proper site

Good morning,

I have the following on
http://www.barbaraling.com/rediresp.php

<?
if(!$ca){
$ca=1;
} else{
$num = array(
1 => "http://www.auctionupperhand.com/",
2 => "http://www.auctionupperhand.com/recruiting/index.html"
);
}
Header( "Location: $num[$ca]");
?>


I would assume that if $ca is not defined, it would
default to the first option (ie, auctionupperhand).
But it goes to the site on which its hosted
(barbaraling.com).  Might someone point out
where I've been clueless?

Thank you in advance,

Barbara Ling
0
lingstar
Asked:
lingstar
1 Solution
 
_Niko_Commented:
Hi Barbara,

when your script hits the if-clause without having $ca being initialized, you set $ca to 1 but the array $num remains uninitialized.

Therefore your redirect is something invalid as $num does not exist in this case.


<?
     if(!$ca)
     {
          $ca=1;
     }

     $num = array(
                    1 => "http://www.auctionupperhand.com/",
                    2 => "http://www.auctionupperhand.com/recruiting/index.html"
               );
     
     Header( "Location: $num[$ca]");
?>

Regards
 Niko


PS: Watch out for your php configuration of register_globals when you are passing $ca through a link or form. ($_GET['ca'] or $_POST['ca']).

0
 
lingstarAuthor Commented:
Thank you thank you thank you!!!!!!!!!!!!

I greatly appreciate your insights, they
were most helpful.

Best wishes,

Barbara Ling
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now