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
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.
And the database will be created as the name what we given
After the database created, we have to create a table. Name of the table and number of columns we want, and click Go.
Filll all the field without fail, and click save to finish the table creation.
Form Creation and action
Here we are going to insert values through form. Mainly database connection and insert code.
$con = new mysqli(‘localhost’,’root’,”,’abcd’);
$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’)”);