I am a newbie to submit a form. All N forms must be submitted to the same page for data processing, that is, writing data to the database. Add. php & lt; formaction = & quot; adddate. php & quot; method = & quot; POST & quot; id = & quot; form1 & quot; name = & quot; fo form submission
I am a newbie. please take a look.
All N forms must be submitted to the same page for data processing, that is, writing data to the database.
Add. php
Add2.php
Add3.php
Adddate. phpHow should I write this page?
$ Con = mysql_connect ("localhost", "root ","");
If (! $ Con)
{
Die ('could not connect: '. mysql_error ());
}
// Some code
Mysql_select_db ("survey", $ con );
$ SQL = "insert INTO information (t1)
VALUES ('. $ t1 ')";
If (! Mysql_query ($ SQL, $ con ))
{
Die ('Error: '. mysql_error ());
}
Echo "script" alert ('OK! 1 record added') script ";
Mysql_close ($ con );
?>
Thank you for choosing adddate. php.
This is a function problem that I don't quite understand.
------ Solution --------------------
Add different parameters to the action of each form to differentiate processing:
PHP code
# Add. php # add2.php # add3.php
------ Solution --------------------
If (isset ($ _ POST [t1])
$ SQL = "insert INTO information (t1) VALUES ('{$ _ POST [t1]}')";
If (isset ($ _ POST [t1])
$ SQL = "insert INTO information (t2) VALUES ('{$ _ POST [t2]}')";
If (isset ($ _ POST [t1])
$ SQL = "insert INTO information (t3) VALUES ('{$ _ POST [t3]}')";
No function is required.