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
i believe it will not work as input data should be insert in two different tables with many if/elseif/else conditions, so it could make mess… as from are too long with different conditions
Your pseudo code and written description doesn’t contain enough information upon which to help you. What is the overall top level description of what you are doing?
yes sir, right now i have two form later i will have more form, so i want one submit button to submit all of form that will insert data into database into different tables, right now im using to submit button for two form, which does make any sense for having two form on same page, so i want one submit button data to database, after submitting data it will be redirect to update page carry all data in field that user just enter in add page form
Finally, that’s the description of what you are actually trying to do.
This is the same subject as in one of your other recent threads. The reason you didn’t get any specific help toward this goal in that thread is because the posted code was missing just about everything needed for a secure, complete application and it was filled with unnecessary copying of variables to other variables and outputting raw error information that would only help a hacker.
Before continuing, how frequent will this feature get used, i.e. inserting new data, immediately followed by editing the same data? If someone has a number of new data items to insert, they won’t want to keep having to cancel the edit page and go back to the insert page to do so.
Anyways, the absence or presence of an id (auto-increment primary index) in a hidden form field is what you need to use to control if you are inserting new data or updating existing data.
Is the reason you think you need multiple forms at once because the data is going in different tables? What exactly is this data and the tables it is going to? Explain what you are doing as though you are describing it to a non programmer. What is the real problem you are trying to solve by doing all this?