The INSERT INTO statement is used to insert new records in a table.
The INSERT INTO statement is used to add new records to a database table.
It is possible to write the INSERT INTO statement in two forms.
The first form doesn't specify the column names where the data will be inserted, only their
The second form specifies both the column names and the values to be inserted:
get PHP to execute the statements above we must use the mysql_query() function. This function is
used to send a query or command to a MySQL connection.
In the previous chapter we created a table named "Persons", with three columns; "Firstname",
"Lastname" and "Age". We will use the same table in this example. The Below
example adds two new records to the "Persons" table:
Now we will create an HTML form that can be used to add new records to the "Persons"
Here is the HTML form:
When a user clicks the submit button in the HTML form in the example above, the form data is sent
The "insert.html" file connects to a database, and retrieves the values from the form
with the PHP $_POST variables.
Then, the mysql_query() function executes the INSERT INTO statement, and a new record will be
added to the "Persons" table.
Here is the "insert.html" page:
Your Query was successfully sent!