Redirect after form submit

Discussion in 'PHP' started by meannn, May 2, 2010.

  1. #1
    Hello,

    My search script automatically open this page after search form

    E.g: xxx.com/?title=madonna+music

    But I have a rewrite url in htaccess and I want to redirect user after search to this url

    E.g: xxx.com/search/madonna/music/


    How can I do that ? Thanks...
     
    meannn, May 2, 2010 IP
  2. Bohra

    Bohra Prominent Member

    Messages:
    12,573
    Likes Received:
    537
    Best Answers:
    0
    Trophy Points:
    310
    #2
    well make a processor which catches the get url and redirects it to that page
     
    Bohra, May 2, 2010 IP
  3. danx10

    danx10 Peon

    Messages:
    1,179
    Likes Received:
    44
    Best Answers:
    2
    Trophy Points:
    0
    #3
    Untested.

    <?php
    if (stristr($_SERVER["REQUEST_URI"], "/?title=")) {
    if (!empty($_GET['title'])){
    $term = str_replace("+", "/", strip_tags($_GET['title']));
    header("Location: http://xxx.com/search/".$term."/");
    } else {
    header("Location: http://xxx.com/");
    }
    }
    ?>
    PHP:
     
    danx10, May 2, 2010 IP
  4. Lam3r

    Lam3r Active Member

    Messages:
    235
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    60
    #4
    header-location is usually pretty buggy unless it comes first in the code, so i would try:
    
    header("refresh: 2; url=http://site.php");  // 2 = time to wait before redirecting, in seconds. url is obvious.
    
    PHP:
    hope that helps ya :)
     
    Lam3r, May 2, 2010 IP