redirect to variable url

Discussion in 'PHP' started by adamjthompson, Dec 1, 2005.

  1. #1
    Hi,

    I have a form on index.php of my site. the form action is to rd2results.php, which then needs to redirect to websearch.php?key={keyword}

    I need to take the keyword entered in the form on index.php & insert it into the url that rd2results.php redirects to.

    Can't find instructions on how to do this...anyone know how?

    Thanks!

    Adam
     
    adamjthompson, Dec 1, 2005 IP
  2. frankm

    frankm Active Member

    Messages:
    915
    Likes Received:
    63
    Best Answers:
    0
    Trophy Points:
    83
    #2
    at the top of your index.php page:

    
    <?
     if ($_GET["keyword"])
     {
        header("Location: http://www.yellow.com/websearch.php?key=" . urlencode($_GET["keyword"]) );
        error_log("Redirected search query to /websearch.php?key = " . $_GET["keyword"]);
        die();
    }
    ?>
    
    <html>
    etc.
    
    
    PHP:


    replace $_GET with $_POST if your are using METHOD="POST" in the actual form.
     
    frankm, Dec 1, 2005 IP