Insert data from HTML form to Database using PHP mysqli: Friends, since we have come to step number 6 in the website design and development session. We need to gradually connect php coding with HTML coding on our website. I mentioned earlier that a user friendly website would require PHP, HTML, CSS and JavaScript equally.
In today’s article we will learn how to insert data from HTML form to MySQL database? Friends, this process is very simple and straightforward. It seems difficult if you don’t know it normally. But friends, in fact it is a very simple process.
Also Read: Insert html form Data to mysqli Database using PHP
Also Read: Send Email using php from html Contact Page – Website Design Step 5
No worries we will discuss the matter in a very simple way and I hope that after you have completed this article all your problems will be solved and you will be able to understand it effortlessly.
If you haven’t seen the steps before the web design and web development session, you will have trouble understanding. So please take a look at the previous steps and it will be very easy for you to understand the whole thing.
We have already learned in step by step how to create html form using html code. Similarly today we will create registration form using html code. I hope you remember the contact page we created using HTML in the previous step.
What is the mysql database?
In a word, it is the place where we store all the data. This database is required when a website has a registration system. We will need a database if we create any registration system in this website. So friends, in a word, a database is a place where all user information is stored for later use.
When a user registers, they enter all their details into the HTML form and when they click the submit button, all the details of that user will be saved in this MySQL database. Users will be able to customize and use it as needed.
Things needed to save data in a database
We must have a hosting to save the MySQL database user data. Since we are working on a live hosting server we do not need it. For those who do not have a live web hosting server, you must buy web hosting server.
Why do we need a hosting server for MySQL Database?
This MySQL Database System will only be available on the Live Hosting Server except that we cannot store data in the Database. So this hosting will be required to use MySQL Database.
How to create MySQL database?
To create a database within MySQL Database, we must first login to cPanel. After the cPanel is successfully logged in, its interface will look exactly like this. In this we will see the Database option.

To understand correctly, I have hidden the above options. When I click on the plus button again, the hide options will appear again.
Now we need to click on the MySQL Database option to create a new database.

Clicking on the MySQL Database option will open a new page. Within this page we will create a new database with a new name and this page is used to set up the whole database.

Create New Database In this box we need to enter the name of the database. Then click on the Create Database button. Then our database will be created. For example- I have named the database here as “test_database“.
Also Read: How to Create HTML Contact Page -Website Design Step 4
Once the database is successfully created, if we move that page down a bit, we will see the Database username option. From there we have to create “Database Username“.

I used the database name as the username (“test_database“) in the database here for example and set up a password of my choice. You can set up the username of the database as you wish. If required, the password can be created by clicking on Generate Password. You can set the password as per your requirement.
After entering the username and password of the database, click on the Create user button, then the username of the database will be created and the password will be created. After creating the database username and password, click on the back button and you will return to the previous page.
When you go back to the previous page, scroll down the page a little, there is an option that is Add User To Database. Now we have to add the username that we created with our database.

Select the username we created from the Username option and select the name of the database we created from the Database option then click the “Add” button. After clicking on the add button, a new page will open. The name of that page is Manage User Privileges.

Click on the ALL PRIVILEGES option and click on the Make Changes option below. Click on the Make Changes option our database will be completely created. Now have to go to the home page of our cPanel by clicking on the home button of our cPanel.
To open the database we created, you need to click on the “phpMyAdmin” option from the cPanel Database tab.

When you click on the phpMyAdmin option, a new tab will open immediately. Our mysql database will open in this new tab. here we will Insert data from HTML form to Database using PHP mysqli.

Friends I hope in this article I have explained to you exactly how to create MySQL database. Friends, in this article, the whole subject could be discussed effortlessly, but since we have discussed a new subject, we have to practice many times to understand it correctly, so we did not discuss the whole subject in this article. This is why in this article we have learned to create only database. In the next step we will learn how to store data from HTML form in MySQL database using PHP code.
The last few words
I hope you enjoyed today’s article. Please share it with your family and friends. If you have any problems with this article, please let us know in the comment box. We will try to resolve your comment as soon as possible.
The steps shown in this article are: If you have trouble creating or understanding the database, please let us know in the comment box. We will try to resolve this issue as soon as possible.