Please Login or Register to continue.


(4.3K Points)
in PHP


1 Answer
(2.4K Points)

PHP code for inserting data into the database from the form.

You can insert the data into the database from the HTML form using  PHP. Insert operation is executed by the insert query of MYSQL. You need to know about the MySQL insert query.  How to work insert query and how exactly target the table where we want to insert out HTML form data.  You have to need focus on the MYSQL queries. After that move on to PHP.  PHP helps to connect the HTML form to the database.  Without PHP you can not perform the insert operation. 


1. First of creating a database  XYZ etc. 

2. Create a table to insert the data. 

3. After that create an HTML form. Decide your form fields. How many fields do you have to need to insert into the database? 

Like - 



Mobile no 

Password etc


4. Now your HTML code (form) is ready. You need to create a PHP code to insert the data into the database.

PHP code for inserting data into the database - 

Create a PHP code to insert the data into the database using MYSQL query. 

1. Create a connection 

$cser=mysqli_connect("localhost","root","","dbname") or die("connection failed:".mysqli_error());


Your server address - localhost 

username - root

password - null (default password is empty ) 

database - dbname . 


2.PHP  insert query.

$result = mysqli_query($cser, "INSERT INTO tablename(name,email,address) VALUES('$name','$email','$address')");

As you know that insert operation required an insert query. 

 INSERT INTO tablename(name,email,address) VALUES('$name','$email','$address')
INSERT Into "table name " 

name, email, the address HTML form fields. 

PHP code for inserting data into the database from form


Related Questions :-

Featured Items:-

Certificate system in PHP website | PHP scripts


Home Credito loan finance management multipurpose system in PHP


Result management system with Marksheet in PHP website | PHP Scripts


Your Answer

You can post your answer after login..