Home >Backend Development >PHP Tutorial >Simple code for PHP to submit data and add records to MySql_PHP Tutorial
Today a webmaster asked Liehuo a very simple question - how to use PHP to add records to Mysql? Now I will give you a simple code to store data, with a few words of analysis, experts will not Look, very basic example.
There are three steps for PHP to write data to the MySQL database:
1. Establish a connection between PHP and MySQL
2. Open the MySQL database
3. Accept the page Data, PHP is entered into the specified table
Steps 1 and 2 can directly use a database link file: conn.php
Of course, the premise is that the WEB server, PHP and MySQL have been installed, and the MySQL table "cnbruce" has been created
The three parameters in mysql_connect() are MySQL address, MySQL username and MySQL password
Then the data is transferred through the WEB page, and PHP writes the data into the table specified in the MySQL database through SQL statements, such as creating a new file liehuo_net.php
Copy to ClipboardQuoted content: [www.bkjia.com] require_once("conn.php");//Reference database link file