1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

PHP Coding Question

Discussion in 'BlackHat Lounge' started by nam6641, Dec 18, 2008.

  1. nam6641

    nam6641 Supreme Member

    Joined:
    Nov 15, 2008
    Messages:
    1,476
    Likes Received:
    914
    Location:
    East Coast
    i want to set up a php rotator redirect... i tried modifying a code i found on here but it always keeps redirecting to Yah00 and never G00gle or Ask.

    any clues from PHP coders?

    Code:
    <?php
    //Add as many links you want
    $mylink[] = header( 'Location: http://ask.com' ) ;
    
    $mylink[] = header( 'Location: http://google.com' ) ;
    
    $mylink[] = header( 'Location: http://yahoo.com' ) ;
    
    
    
    
    // this will display the random link
    echo $mylink[array_rand($mylink)];
    ?>
     
  2. thanhclix

    thanhclix Power Member

    Joined:
    Oct 25, 2008
    Messages:
    646
    Likes Received:
    176
    Try this
    Code:
    <?php
    $mylink[0] = "http://ask.com";
    
    $mylink[1] = "http://google.com";
    
    $mylink[2] = "http://yahoo.com";
    $lenght = count($mylink) - 1;
    $i = rand(0, $lenght);
    header('Location: '.$mylink[$i]);
    ?>
    or this
    Code:
    <?php
    	$i = rand(0, 2);
    	if($i==0){
    		header('Location:http://yahoo.com');
    	}
    	if($i==1){
    		header('Location:http://google.com');
    	}
    	if($i==2){
    		header('Location:http://ask.com');
    	}
    		
    ?>
     
    • Thanks Thanks x 1
  3. nam6641

    nam6641 Supreme Member

    Joined:
    Nov 15, 2008
    Messages:
    1,476
    Likes Received:
    914
    Location:
    East Coast
    i tried the 2nd one and it worked perfect. thanks bro.
     
  4. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    787
    Likes Received:
    3,118
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    can this be adjusted to rotate banners?
     
  5. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    787
    Likes Received:
    3,118
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    yep, it can be. in fact i just did it! :D