I am working on a website where I have 2 forms on 1 page. I use 1 PHP script to check the forms. But if I submit my second form on the page, my website submits the first form. How can I check which form is submitted?
<!--// Form 1-->
<form method="post">
<input type="text" name="test">
<input type="submit" name="submit">
<input type="hidden" name="page_form" value="1">
</form>
<!--// Form 2-->
<form method="post">
<input type="text" name="test">
<input type="submit" name="submit">
<input type="hidden" name="page_form" value="2">
</form>
PHP:
if(isset($_POST['submit'])) {
$forms = array(1, 2);
foreach($forms as $form) {
if($_POST['page_form'] == $form) {
// All my form validations which are for every form the same.
}
}
}
HTML
decides to submit the 1st form when clicking on the second? Never run into that!?! – Siamvalue
as in here #9538418? – Siam