Php 如何将多个表单中的一个提交到mysql数据库中的独立表中?

Php 如何将多个表单中的一个提交到mysql数据库中的独立表中?,php,mysql,forms,Php,Mysql,Forms,以下是我现有的代码: <?php if (isset($_POST['submitForm'])) { print_r($_POST); } ?> <form action="" name="form1" method="post"> <input type="text" value="" name="A" /> <input type="text" value="" name="B" /> <input

以下是我现有的代码:

<?php
     if (isset($_POST['submitForm'])) { 

    print_r($_POST);

     }

?>
<form action="" name="form1" method="post">
<input type="text" value="" name="A" />
<input type="text" value="" name="B" />
<input type="text" value="" name="C" />
<input type="text" value="" name="D" />
<input type="Submit" value="Submit Form" name="submitForm" />
</form>

<form action="" name="form2" method="post">
<input type="text" value="" name="A" />
<input type="text" value="" name="B" />
<input type="text" value="" name="C" />
<input type="text" value="" name="D" />
<input type="Submit" value="Submit Form" name="submitForm" />
</form>

<form action="" name="form3" method="post">
<input type="text" value="" name="A" />
<input type="text" value="" name="B" />
<input type="text" value="" name="C" />
<input type="text" value="" name="D" />
<input type="Submit" value="Submit Form" name="submitForm" />
</form>

这仅仅是张贴任何一个单独提交的表单

我试图完成的是将这些单独的表单提交到同一数据库中的特定表中


例如,Form1将被提交到Table1,Form2将被提交到Table2,等等。每个表单都将被提交到它的匹配表中

将提交输入表单元素的每个元素的名称更改为submitForm1、submitForm2和submitForm3,如:

<input type="Submit" value="Submit Form" name="submitForm1" />

<input type="Submit" value="Submit Form" name="submitForm2" />

<input type="Submit" value="Submit Form" name="submitForm3" />

$\u POST或$\u GET数组是输入标记的组合。因此,当您调用$\u POST['submitForm']时,您应该有一个输入,其名称如下

 <input name ='sumbitform' />

如果您需要获得单独的表单,只需通过以下方式更改代码:

<?php
 if (isset($_POST['submitForm1'])) { 

 //sql statement for table 1 there

     }

if (isset($_POST['submitForm2'])) { 

    //sql statement for table 2 there

     }

if (isset($_POST['submitForm3'])) { 

    //sql statement for table 3 there

     }

?>
<form action="" name="form1" method="post">
<input type="text" value="" name="A" />
<input type="text" value="" name="B" />
<input type="text" value="" name="C" />
<input type="text" value="" name="D" />
<input type="Submit" value="Submit Form" name="submitForm1" />
</form>

<form action="" name="form2" method="post">
<input type="text" value="" name="A" />
<input type="text" value="" name="B" />
<input type="text" value="" name="C" />
<input type="text" value="" name="D" />
<input type="Submit" value="Submit Form" name="submitForm2" />
</form>

<form action="" name="form3" method="post">
<input type="text" value="" name="A" />
<input type="text" value="" name="B" />
<input type="text" value="" name="C" />
<input type="text" value="" name="D" />
<input type="Submit" value="Submit Form" name="submitForm3" />
</form>

<?php
 if (isset($_POST['submitForm1'])) { 

 //sql statement for table 1 there

     }

if (isset($_POST['submitForm2'])) { 

    //sql statement for table 2 there

     }

if (isset($_POST['submitForm3'])) { 

    //sql statement for table 3 there

     }

?>
<form action="" name="form1" method="post">
<input type="text" value="" name="A" />
<input type="text" value="" name="B" />
<input type="text" value="" name="C" />
<input type="text" value="" name="D" />
<input type="Submit" value="Submit Form" name="submitForm1" />
</form>

<form action="" name="form2" method="post">
<input type="text" value="" name="A" />
<input type="text" value="" name="B" />
<input type="text" value="" name="C" />
<input type="text" value="" name="D" />
<input type="Submit" value="Submit Form" name="submitForm2" />
</form>

<form action="" name="form3" method="post">
<input type="text" value="" name="A" />
<input type="text" value="" name="B" />
<input type="text" value="" name="C" />
<input type="text" value="" name="D" />
<input type="Submit" value="Submit Form" name="submitForm3" />
</form>