How To Insert Form Value Into MYSQL Database using PHP | Mysql Inserting Data Into Tables

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hello everyone today I'll show you how to insert a form value into database first of all we will create a stable form structure so here I'm writing doctype HTML which tells browser the HTML version now we'll write HTML tag and it's closing tag so inside this HTML form we will write our head tag and it's closing tag and after this head tag we will create our body tag and it's closing tag so this is basic a steamer form structure now we will save this file inside our htdocs folder we have created a folder form so we will save this file with index dot PHP click on save inside this head tag we will write our phone title so from title will be insert form value into database inside a body tag we will create our form tag through which user input their data so we will use two attributes for this form tag first will be action and second will be method to know about these attributes lochia actually specifies where the form data is to be sent after submission and Method specifies how to send form data so there are two methods get method and post method now we will create our input box so we'll write patek type will be 'text and name will be name your name attribute identifies the value of input box into database so we will create a label for this input box so first label will be name now we will write we are dying to separate the lines like this way we will create some more input boxes secondly will will be email type will be email and name will be email also next will be each type will be 'text and name will be each last one we will create with name of address that will be taxed and name we will write address at last we will create our button through which we submit our form into database so button value will be submit button diaper submit and mean will also be submit now we will save this file with ctrl + s and we will check this form into our browser so write localhost / form here you can see our form now I'll show you how to create database so first of all we will open localhost / PHP myadmin click on and down here you can see PHP myadmin so firstly select a database create a new database writing insert and click on create now we will create a table so write the table name form and number of columns will be 5 click on go yeah we will give the name and data right so first will be ID data type in T so and click on auto increment second will be name data type will be variable character width the length of 20 next is email data type will be variable character width the length of 20 next is each data type will be in T so with the length of 11 and the last we will write address data type is variable character and length is 50 click on save now you can see the table we have created all these namings are coming from the form which we have created you can see here now we will write a code to save the value in to database so here I'm going to create another file and I'll save it inside the htdocs folder and the name I will give it insert dot PHP click on save now in our form action we will write this file name method here we will use post because you can see post is secure method now we will write our code so first of all we will create our parameters to make connection with database server will be localhost username is root in which is PHP myadmin look as flower localhost username so password will be empty and the last is our database name so we will write database name insert you can see we have created a database with insert name here now we will write a connection so here mass july underscore connect and inside this we will write our parameters so first will be server the second will be using him third will be password and the last parameter is database name now we will check a condition if form is clicked on submit or not so we will write if is set dollar underscore post submit because we safe one with the post method so here we will fetch the values through dollar underscore post method so now we will check if all input boxes are empty or not so firstly we will check our first box value so first value is name now we will apply the same condition for all other input boxes so next box is email third is each and the last will be address so after checking this condition if it works we proceed further else we will print a message all fields required now inside this condition we will fetch all the values from the form so you're I'm going to fetch the value of name and I'm storing this value inside the dollar name variable second is email you dollar underscore post email next value will be each and the last value will be addressed so I'm going to store this value inside the dollar address variable now we'll write a query and sort into form which is our table name so I'll create the table columns name name email each an address now inside this we will put values these values are the values which we fetch through the form so here I write doe learning next will be dollar email last value will be dollar rates and the last will be dollar address like this way we will see the values into database through our form now we will run our query so here I'm gonna write my skew line underscore query there are two parameters for this first will be connection and next will be query or we will write die mask you'll i underscore error so in case a query won't run it will throw an error now we will check this condition that if this query will run we will print a message form submitted successfully otherwise we will print the message form not submitted now we will save this file with ctrl + s now we will put values in our form name email each and now address now the submit this form you can see form some red successfully now we'll check values in database so here you can see name email age and address thanks for watching please like share and subscribe our Channel
Info
Channel: wpshopmart
Views: 52,915
Rating: undefined out of 5
Keywords: PHP, MYSQL, insert query in php, PHP Insert Data in Database, How To Insert Data in Database, Database, PHP Database, PHP Tutorial, Learn PHP, PHP Basic, PHP Development, Notepad++, PHP Programming, Web Development, PHP Series, PHP Lessons, How to, Tutorial, php, insert, mysql, MySql Tutorial for Beginners, How To Insert Form Value Into MYSQL Database using PHP, entry of data, Mysql insert query, Mysql Inserting Data Into Tables, How to save forms value into database using php
Id: -WiWjYnTmXM
Channel Id: undefined
Length: 13min 11sec (791 seconds)
Published: Fri Feb 28 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.