How to Insert Form Data into Database using PHP

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi everyone in this video we will insert Forum data into the database okay using PHP I am using the jump server I have installed it and I have created a folder and C drive zamp and https by the name of which okay I've created this folder and I have two files DB connection and uploaded page view so let's go there so let's write our code first we will create the connection with some server so to click the connection let's start PHP script connection is equal to mySQL I connect and here first thing is that our server our server is local asked then the username the username is the root by default and the password we don't have password and in the database name the database name is crowd with us okay let's show you the database name it's third database name and card operation um table name and we have these pairs in that columns now if con was equal to equal to with false die connection here and display us my sqli connect error okay we wrote our connection so now let's use it so here uh first of all I will create a form to insert the data to the database so let's write HTML code for that in the data to DB using PHP scar and just try to form here margin oh it should be styled let me just try some style for this [Music] and right side here first of all the input field would be for Todd should be text name should be name and set up Place folder enter name same to this I will add for the email and for the address it is email with us name should be email enter email and simple the address text name should be address and enter let's write a button let's submit type should be submit and name is equal to in submit so now whenever we press this button so we should where to go if you would like to pass our data to a separate file for example I would like to write my code in a separate file in separate PHP file so then I should mention that okay in the action action is equal to Azure for example there is a file by the name upload data.php I have created that here so then I should write something like this if I would like to write the PHP code in the same file so then I don't need this I will just write them the method the method should be post so now let's write our PHP script here I will first I will import include the connection include DB connection dot PHP that we have created a H here f is C2 if the submit was set submit if it was zipped within or we will get our data first the name is equal to post name same to this we have email and address let's try to semicolon so after that we will use our we will write our query so I will use the query is equal to MySQL I query and this function and first I will pass the connection variable I have created in this file okay this connection this one after that I will write my query here insert into a current operation I didn't know we specified the column name first one is the name then the email and address I have the column names are the same so let's check it yeah name email and address after that the values the video is the first value would be name the second one would be email and the third one would be address after writing this so now let's check if the query was okay so then we will print something just like equal alert data inserted successfully else there is an error so now let's send our this file so let's come to the Chrome first we will go to the Local Host then the fetch folder okay in the fish folder we will go to upload.php okay we have so it should be a pattern a multi okay okay we have this data so first of all let's enter the name how at gmail or Yahoo .com and the address should be like new address shifted after that let's press the submit button uh the teacher didn't enter I think and didn't execute it a method is posed form and the type submit name submit and let's come here and include DB connection.php f is it post submit the data and we will insert into crowd crowd it the name mistake okay crowd operation name email address values yeah so let's check it so let's enter the name press shift submit it not entered again what where is here so let's check it my cpli query so just the problem was that was not we were not getting this message because we should wrap it in the single quotation the message alert message and now let's come here and distribution page and make it like this come here Khan at yahoo.com right now we don't have any database this is uh regardless appreciate see we don't have that record so now let's insert it press the submit data is that it's successfully okay so now let's come and differentiate again see the new record has inserted to the database so it was all about inserting a or data to the database using PHP if you have liked this video so please subscribe our YouTube channel and thanks for watching
Info
Channel: Code With Yousaf
Views: 19,210
Rating: undefined out of 5
Keywords: how to insert form data into database using php, insert form data into mysql database using php, how to insert data in database, how to insert data into a database using php, how to insert form data into mysql database using php, insert data into database using php, insert html form data into database using php, php insert data into database, php insert data into database mysql, how to connect form with database in php, how to connect form with database
Id: I-YuuFxZcdk
Channel Id: undefined
Length: 10min 41sec (641 seconds)
Published: Tue Feb 21 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.