PHP variable redirect to external website?

Discussion in 'PHP' started by chriswick, Feb 23, 2008.

  1. #1
    Hello everyone I want to send a variable into a redirect page? I was using the code below but with no luck. + Rep, for the first person that posts a solution.

    Here's my code.

    <?php
    header( 'Location: http://www.domain.com/<?php echo str_replace("\\", "", $_GET[id]); ?>">' ) ;
    ?>
    PHP:
    I also made this code by it's not working either?

    <?php
    
    $id = $_GET['id'];
    
    header('Location: 'http://www.domain.com/[$id]');
    
    ?>
    PHP:

     
    chriswick, Feb 23, 2008 IP
  2. norfstar

    norfstar Peon

    Messages:
    1,154
    Likes Received:
    62
    Best Answers:
    0
    Trophy Points:
    0
    #2
    This isn't tested, but try:

    <?php
    header( 'Location: http://www.domain.com/'.str_replace("\\", "", urlencode($_GET['id'])));
    ?>
    PHP:
     
    norfstar, Feb 23, 2008 IP
    chriswick likes this.
  3. chriswick

    chriswick Peon

    Messages:
    907
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Yes that works, +Rep!
     
    chriswick, Feb 23, 2008 IP