×

Please Login or Register to continue.

2
(405 Views)

(4.2K Points)
in PHP

Share

1 Answer
(2.2K Points)
0

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 - 

Name 

Address. 

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


Comment

Related Questions :-

Featured Items:-


Certificate system in PHP website | PHP scripts

$37



Home Credito loan finance management multipurpose system in PHP

$98



Result management system with Marksheet in PHP website | PHP Scripts

$48




Your Answer

You can post your answer after login..