Blog Details

PHP Database Tutorial

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 Using PHP. First I will create a Database as a Tutorial create Database is created as you can see Database tutorial Now I will create one table as a person First column ID type integer and it will be auto increment when we use auto increment mode we don’t 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 let’s 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 an 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 visible unique URL the name attribute is required when we have to use this data in PHP the break line

PHP Database Tutorial
PHP Database Tutorial


Submit button input type=submit value=”Insert” end form now HTML form is ready now I will create PHP script I will save it as an insert.

php first i will crete conncetionj for Databse $ sign is used to declare variable $con = mysqli_connection(‘127.0.0.1′,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.

Author

  • Era24UK

    Hello, I am a hosting & web specialist with 19 years of experience. I love to work hard all the time. Success is not an accident it is hard work, I believe it. I'm here to Provide My Service and Help people grow and find success in any way I can. Feel free to contact me!

    View all posts

Leave A Comment

five × 2 =

Cart

No products in the cart.

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare