Trending News
Home / Web Development / HTML / Create Database with MYSQL and Insert Code in PHP

Create Database with MYSQL and Insert Code in PHP

We are going to discuss about ‘how to create database and how to insert the field values in the database using php form’. This application used into all projects like registration form or insert the values to database operations.

Table Of Content

    • Database Creation
    • Table Creation




  • Form Creation and action

Database Creation

For creating database I am using WAMP sever, go to the localhost url and choose phpmyadmin(localhost/phpmyadmin) and click on the database then fill the name of the database and then click CREATE.

createdatabase1



And the database will be created as the name what we given

createdatabase2




Table Creation

createdatabase3



After the database created, we have to create a table. Name of the table and number of columns we want, and click Go.

createdatabase4

Filll all the field without fail, and click save to finish the table creation.

Form Creation and action

createdatabase5




Here we are going to insert values through form. Mainly database connection and insert code.

Database connection:

$con = new mysqli(‘localhost’,’root’,”,’abcd’);

Insert coding

if(isset($_POST[‘submit’]))
{
$uname=mysqli_real_escape_string($con,$_POST[‘name’]);
$email = mysqli_real_escape_string($con, $_POST[’email’]);
$name = mysqli_real_escape_string($con, $_POST[‘name’]);
$pass = mysqli_real_escape_string($con, $_POST[‘password’]);

$sql_row2=mysqli_query($con,”INSERT INTO registration(name,email,username,password)values(‘$uname’,’$email’,’$name’,’$pass’)”);

}

createdatabase6



FULL CODE

 

Registration Form

 

 


 


 


 


 

 

 




Loading Facebook Comments ...
Social Media Auto Publish Powered By : XYZScripts.com