How can I can do multiple redirects with php?

Discussion in 'PHP' started by locpicker, Sep 23, 2009.

  1. #1
    I am working on a new program that sends info from an html pageform and goes to a php form for verfication and redirecting. My problem is I cannot figure out what php command to use for the redirect.

    I also would like it to go to a relative url.

    Here is an example of what I was considering but I doubt very seriously if this will work.

    gettype($parent);
    
    if(empty($parent))
    
    {
    
    die("No Choice Selected");
    
    }
    
    elseif $parent="boyboth"
    
    (
    
    header("Status: 200");
    header("Location: somesite.com");
    Exit(); 
    
    )
    
    elseif $parent="boyfather"
    
    (
    
    header("Status: 200");
    header("Location: http://somesite.com");
    Exit(); 
    
    )
    
    elseif $parent="boymother"
    
    (
    
    header("Status: 200");
    header("Location: http://somesite.com");
    Exit(); 
    
    )
    
    elseif $parent="girlboth"
    
    (
    
    header("Status: 200");
    header("Location: http://somesite.com");
    Exit(); 
    
    )
    
    elseif $parent="girlfather"
    
    (
    
    header("Status: 200");
    header("Location: http://somesite.com");
    Exit(); 
    
    )
    
    elseif $parent="girlmother"
    
    (
    
    header("Status: 200");
    header("Location: http://somesite.com");
    Exit(); 
    
    )
    
    else exit;
    
    ?>
    Code (markup):
     
    locpicker, Sep 23, 2009 IP
  2. rnc360

    rnc360 Greenhorn

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #2
    Hi!

    header ("Location: url"); shoud work fine, if you don't output anything else before it on your verification page!

    You're bit wrong with your IF structure:

    wrong: elseif $parent="boyboth"
    correct: elseif ($parent == "boyboth")

    == instead of =
     
    rnc360, Sep 23, 2009 IP
  3. dweebsonduty

    dweebsonduty Active Member

    Messages:
    131
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    71
    Digital Goods:
    1
    #3
    I like to print
    "<meta http-equiv="REFRESH" content="0;url=http://www.the-domain-you-want-to-redirect-to.com"></HEAD>"

    in the header 0 being the time to refresh.
     
    dweebsonduty, Sep 23, 2009 IP
  4. locpicker

    locpicker Well-Known Member

    Messages:
    789
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    160
    #4
    Thanks for the tip.

    Can I use somesite.php though as a relative url or am I going to have to use the entire url address for each one?
     
    locpicker, Sep 23, 2009 IP
  5. rnc360

    rnc360 Greenhorn

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    16
    #5
    If the somesite.php file is in the same directory where is your verfication script file, then you can easily use as link just somesite.php filename!
     
    rnc360, Sep 23, 2009 IP