0

im trying to insert data into database with two different form into two different tables with single button. Both Form are in same page.

Form-1 (inserts data in table-1)

if(isset($_POST['form_1'])){
Insert Query with condition
}

<form action="" method="post">
   Different field for  requried for database field entry
    <input type="submit" value="Publish" name="form_1">
</form>

Form-2 (inserts data in table-2)

if(isset($_POST['form_2'])){
Insert Query with condition
}

<form action="" method="post">
   Different field for  requried for database field entry
    <input type="submit" value="Publish" name="form_2">
</form>

As we can see, i have used post method for form submission, it insert user input data into database with:

isset(isset($_POST[‘submit name’]))

i have used different submit button for inserting data, i want use single button to insert user input into database which table are different

How can i use single button to submit the data to two different table

esu
  • 11
  • 2
  • 3
    Use a single form, name your input elements accordingly – brombeer Jun 28 '22 at 14:20
  • You can't submit two forms at once. Use a single form containing all the necessary fields, and a single button - and a single PHP script to process it and do all the necessary database inserts – ADyson Jun 28 '22 at 14:20

1 Answers1

0

You mean

<form action="" method="post">
   Different field required for database field entry
  <input type="hidden" name="form_1" value="Publish">
  <input type="hidden" name="form_2" value="Publish">
  <input type="submit" name="subbut" value="Publish">
</form>
mplungjan
  • 169,008
  • 28
  • 173
  • 236