how do i redirect after form is submitted?

Discussion in 'PHP' started by whiteblue1942, Apr 12, 2008.

  1. #1
    how do i make the user go to a new page after the registration form is submitted? here is my code and once they fill out this form i want them to go to a new page

    if ($result){
    echo "go to new page";
    }
    else{
    echo "aww man no biggie";
    }
    
    ?>
    
    <form action="new.php" method="post">
    <p>First Name: <input type="text" name="firstname" size="15" maxlength="20" value=""/></p>
    <p>Last Name: <input type="text" name="lastname" size="15" maxlength="20" value=""/></p>
    <p>Email: <input type="text" name="email" size="15" maxlength="20" value=""/></p>
    <p>Password: <input type="text" name="pass" size="15" maxlength="20" value=""/></p>
    <p><input type="submit" name="submit" value="register"/></p>
    <p><input type="hidden" name="submitted" value="TRUE"/></p>
    </form>
    Code (markup):
     
    whiteblue1942, Apr 12, 2008 IP
  2. Xtrm2Matt

    Xtrm2Matt Active Member

    Messages:
    129
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    58
    #2
    if ($result){
    header("Location:newpage.php");
    }
    else{
    echo "aww man no biggie";
    }
    PHP:
     
    Xtrm2Matt, Apr 12, 2008 IP
    whiteblue1942 likes this.
  3. whiteblue1942

    whiteblue1942 Peon

    Messages:
    573
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #3
    i tried that that then the page just redirected before it even loaded, you coudlnt even fill out the form and it sent you to the new page
     
    whiteblue1942, Apr 12, 2008 IP
  4. whiteblue1942

    whiteblue1942 Peon

    Messages:
    573
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    0
    #4
    nevermind i just put my entire php code in an if statement so it didnt run as soon as th erpage laoded, and your script worked! thanks man a ton rep added!
     
    whiteblue1942, Apr 12, 2008 IP
  5. jjacquay712

    jjacquay712 Peon

    Messages:
    8
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    you could also use a meta tag to redirect
     
    jjacquay712, Apr 12, 2008 IP