It is essential for WEB developers to keep the data submitted by users to the mysql database. Let's take a look at how to save the data submitted by users to the database. It is essential for WEB developers to keep the data submitted by users to the mysql database. Let's take a look at how to save the data submitted by users to the database.
Script ec (2); script
If ($ _ POST [OK])
{
$ Link_id = mysql_connect ("localhost", "root", "") or die ("connection failed ");
If ($ link_id)
{
// Select a database
Mysql_select_db ("my_test ");
// Insert data SQL statement
$ SQL = "insert into userinfo values ('". $ _ POST [id]. "','". $ _ POST [name]. "','". $ _ POST [gender]. "','". $ _ POST [age]. "','". $ _ POST [regdate]. "')";
// Execute the SQL statement
$ Result = mysql_query ($ SQL );
If ($ result)
{
Echo "the record has been inserted successfully.
Insert record ";
}
Else
Echo "An error occurred while executing the insert SQL statement ";
// Close the database
Mysql_close ($ link_id );
}
}
Else
{
?>
} // End if
?>
Reprinted with www.111cn.net/phper/php.html