Two forms on one page

Discussion in 'PHP' started by OmerHassan, Aug 14, 2009.

  1. #1
    My page has both sign up and sign in forms on it and the action attribute of both forms is set to the same address.
    <form action="verify.php" method="post" name="signup"> ... </form>
    <form action="verify.php" method="post" name="signin"> ... </form>
    HTML:
    Now in verify.php, how do I know whether the data received was submitted through the sign up form or through the sign in form?
     
    OmerHassan, Aug 14, 2009 IP
  2. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You can either use a submit button name="submit" value="Signup" and name="submit" value="Login" to differentiate the two, or simply a hidden field.
     
    premiumscripts, Aug 14, 2009 IP
  3. elitasson

    elitasson Member

    Messages:
    49
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #3
    <form action="verify.php?q=signup" method="post" name="signup"> ... </form>
    <form action="verify.php?q=login" method="post" name="signin"> ... </form>

    Use this php code:

    <?php
    
    if($_GET['q'] == 'signup') {
    
    //signup
    
    }
    elseif($_GET['q'] == 'login') {
    
    //Login
    
    }
    
    ?>
    PHP:
     
    elitasson, Aug 14, 2009 IP
  4. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4

    If you already got a form, there's no sense in adding in the query string to the action= itself, but rather

    <input type="hidden" name="q" value="..."/>
     
    kblessinggr, Aug 14, 2009 IP