1st question is isit ok to have more than 1 form per page? i read dunno where that 1 page shld have only 1 form, true?
assuming you do login and register form in 1 page, i think there are 2 approaches
- 2 separate forms -> isit ok for form input[name] to be reused? eg. both login and register will have username & passwords field
- 1 form. use JS to hide confirmPassword field then at server side check if there is a confirmPassword is filled? upon typing this, this does not seem like a good idea…
Yes, it’s ok.
Yes, it’s ok. You can place two inputs with the same name (in different forms). Only ‘id’ attribute must be unique. You should set different actions for form. For example, the first form will be
<form action='login.php'>, the second –<form action='register.php'>It’s better to create input with type=hidden and place action type in it:
You can change value with Js.
Also you can create two submit buttons in one form:
If login button pressed, the server will receive ‘do_login’ argument. Else, it will receive ‘do_register’.