Insertion of Records into Database using Forms: PHP & MySQL

Video tutorial illustrates INSERTION of records into database using simple HTML form and minimal PHP scripting.

First look at these short videos:
Connect to the database
Simple / basic insertion operation

Form and PHP script, both in one file
index.php

< ?php
 include_once('db.php');

 if($_POST['name'])
 {
   $name = $_POST['name'];

   if(mysql_query("INSERT INTO apple VALUES('','$name')"))
  echo "Successful Insertion!";
   else
  echo "Please try again";
 }
?>

. in action property of html form simply means that the user entered values will be passed on to itself.
Since we are using . in the action property, we are making use of user entered values in the same file by using if($_POST[‘name’]) PHP code.
we can even use if( isset($_POST[‘name’])) isset() is a PHP function to check whether a variable has some value or not.

Video Tutorial: Insertion of Records into Database using Forms: PHP & MySQL



YouTube Link: https://www.youtube.com/watch?v=9BRiX3rXuRg [Watch the Video In Full Screen.]



To know the differences between GET and POST methods:
GET Method In Action: Simple Form
POST Method In Action: Simple Form

Data in the database, as shown in the video:
1. Google
2. Apple
3. Microsoft
4. Oracle
5. Technotip

View Comments

  • Sir, I would like to get job opportunity in programming let me get a hope to do the job with the help of your website. My aim to develop a job portal outsourcing using latest communication equipments for global access to all

  • @rengankhrishnamurthy, My best wishes with you ..keep learning, keep working and you'll be a step ahead each day towards your goal.

  • it is very clear and helpful to me. I was a trouble in some other video tutorials. there is lot of cording parts with so much informations. so it difficult to me take
    the most basic cord