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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
< ?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";
}
?>
 
<form action="." method="POST">
Name: <input type="text" name="name"/><br />
<input type="submit" value=" Enter "/>
</form>

. 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 https://www.youtube.com/watch?v=9BRiX3rXuRg]

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

4 thoughts on “Insertion of Records into Database using Forms: PHP & MySQL”

  1. 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

  2. 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

Leave a Reply

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