PHP – Insert Form Data Into MYSQL Database Using PHP

PHP – Insert Form Data Into MYSQL Database Using PHP

Today i will show you How to insert Form Data in Mysql Database Uing PHP First i will create Database as Tutorial create Database is created as you can see Database tutorial Now i will create one table as person First column ID type integer and it will be auto increment when we use auto increment mode we dont have to insert any value the value is inserted automatically by MYSQlL Second Column Name type varchar and length 20 third Email type varchar again length 20 save table is also created lets check Database tutorial person as you can see ID is auto increment name as varchar email now i will create HTML Form Html head title Insert Form Data In MYSQL Database using PHP end title end head body end body end html i will save it as index.html now i will create one form action=”inset.php” Insert.php page will contain our PHP script to insert data into Mysql Database method=”POST” you can also use get when we use get method the data is viible uin url thi name atytribute i srequired when we have to use this data inp PHP the break line
submit button input type=submit value=”Insert” end form now html form is ready now iwiill created php script i will save it ass insert.php first i will crete conncetionj for Databse $ sign is used to declare variable $con=mysqli_connection(‘′,root”,”); 3 parameters is required user name ass root i.e default check for connection if not echo echo is used to print string now select Database mysqli_select_db($con,’tutorial’) now i will get the value send from the index.html Email=$_POST[’email’]; sql Command INSERT INTO person (Name,Email) VALUE (‘$Name’,’$Email’) mysqli_query($con,$sql) echo “Inserted”; Page should be redirected to index.html after insertion for this i will header(“refresh:2; url=index.html”);

Danny Hutson

84 thoughts on “PHP – Insert Form Data Into MYSQL Database Using PHP

  1. sir it was good.It was working.but I have a one problem.That is not insert a data in MySQL.but "inserted" is show SUCCESSFULLY in the page.Really that is not insert in MYSQL .wt can I do…

  2. I tried this method on one of the form i created and the database is connected but hut while testing when i am adding any data only the id is increasing and entered data is no where in the database. Do you have any solution? Help ASAP

  3. What if I wanted to make the form data into JSON and put it into a native JSON mysql field? How would you encode the data that comes in?

  4. PLEASE HELP my data is not inserting in table. my database is connected, server is connected. It's just not inserting.

  5. Sir….i m hit the submit button doesn't show "inserted "….it shows empty web browser …what can i do for that error sir…!

  6. Best software to convert MS-Sql to MySQL , use coupon code "Aditi123" for discount upto 25% valid till 1-Dec-2018.

  7. Hi After i Inserted my data in formation.html it goes to new1.php but on blank page and no data is inserting in localhost help please!

  8. It works but after last if of mysqli_query($conn, $sql) after it not to executed. All programme is running but in database the data is not uploaded

  9. Thank you so much for that. It's hard to find such bang on tutorials that get straight to the point, and actually work.

  10. first of all you have to provide to source code. second thing you have to explain where you are saving your files. sorry for dislike.

  11. thank you much sir
    aaj finally m sikh hi gaya
    abhi tk itni videos dekhi thi koi nhi sikha paya tha pr aapne sikha diya sir thank u o much

  12. hi, have been trying for 2 months to get this to work 99.999% of these vids are wrong ,ok I used w3school insert data under php,then use form handling w3school ,now eg.input1:<input type="text" name="input1">,input1 will be in your database field that what you want your input to go make sure when you create make it null important,now using php insert code $sql="INSERT INTO table(input1) VALUES ('".$_POST['input1']."')"; it works 2 months man there are people writing code that deliberately mess people up with bullshit,i'm sorry guys so many bad people out there.

  13. Hi I have a problem.
    I've made Registration form in HTML,styled it in CSS,made insert.php and did everything like you did in video,and I've made MySQL database using phpMyAdmin.
    When it comes to registration I've tried to register to see if it works,all my information fields work fine,but when i click submit next thing I see is my php source code,when I should actually see the output I wrote.Also I'm using WAMP app and MySQL is connected properly,so is Apache,and phpMyAdmin.
    Does someone else experience the same problem ?
    How do I fix it ?

  14. When I am clicking on insert , data is not inserted in the database, it opens my PHP script file in browser. Please, anyone help me out.

  15. its was spot-on…. can u pls share the video link of how i can view the data entered upon auto update and also how to create a login form linking the database

  16. i am getting error like this Incorrect integer value: '' for column 'phone' at row 1. What i need to do to come out of this problem

  17. Thanks for this Information. Please check my video on Install Local Server On Android: Web Server PHP/MyAdmin/MySQL click here

  18. Had an issue adding this database online. The online company which uses Shared Hosting gives you a name like: ABCWeb_ So I had to add that to the root user and the tutorial database. The table was okay. So basically, ABCWeb_root, and ABCWeb_tutorial. Also, had to take spaces away from the single quotations like this: ' root " , ' password '). And made it, ('localhost:NUMBERAssigned','ABCWeb_root','password'). and named the tutorial database on another line correctly. This is great when it works. lol.

Leave a Reply

Your email address will not be published. Required fields are marked *