Multiple forms and one processing page

前端 未结 3 1302
盖世英雄少女心
盖世英雄少女心 2020-12-03 09:13

please i need your help with an issue. I have two forms on my homepage that i\'ll like users to fill and submit at different times. My problem is that i\'ll like to have onl

3条回答
  •  星月不相逢
    2020-12-03 09:47

    You can do it on the same page also. Just you need to make action same for both the forms.

    You need to make some condition and write the individual functionality for Form A and for Form B depending on the source form.

    You can check with the parameters in action like @Ami has used.

    /submit.php?action=register or /submit.php?action=activate

    So, you have code like this:

    if ($_GET['action'] == 'register') {
      // Register user
    } else if($_GET['action'] == 'activate' {
      // Activate user
    }
    

    However, you could also just change the value of the submit button and have the action parameter the same for both forms:

    if (isset($_POST['submit'])) {
      if ($_POST['submit'] == 'register') {
        // Register user
      } else if($_POST['submit'] == 'activate') {
        // Activate user
      }
    }
    

提交回复
热议问题