How to create a registration form using php, html, css and mysql database.
Setting up database.
-Open your xampp panel and start your MySQL and Apache server.
-Open your browser and visit
Localhost/phpmyadmin/
-Click on new on the left side bar of php myadmin page.
-Assign a database name and click on create.
-Then assign a table name and choose 3 columns, one for name and others for email and password.
We have successfully setuped our database and tables.
Now we will work on frontend.
Frontend
Create a register.html file
Add little css
this is how our form looks like
Backend
Here, we will code all the logics which required to transfer registered data from html form to the MySQL database.
First create a register.php file
This is the backend code you can copy paste in your file and the code is explained below the code.
-First we have got the post data such as name, email and password from html form with the help of the function $_POST[].
Note:- $email and $password are the variables you create in php you can choose any text as your variable in php, you just need to add '$' before the text to convert it into variable.
-then we created a connection between our database with the help of mysqli_connect() function.
In mysqli_connect() we are using four terms .
Those terms are explained below.
Localhost is the host name of the host where your database is created, for local computer it is localhost or 127.0.0.1
Then root is the username of your local MySQL server if your database is not in your local computer then use the username of MySQL provided by the host.
Then password of your database, here we leaves it empty ("") because we are not using any password in our database but if you use the password then you should also mention it in your code.
Then at the end we are using our database name which is registration.
No comments:
Post a Comment