Insert And Extract/Fetch Data From Database: PHP Script

Advertisement:

What to expect ?
Using PHP script insert user entered data/information into database and extract/fetch data stored in database and display it on the browser.
This video tutorial also teaches the MySQL queries.

In this video tutorial we have used a readymade form which uses POST method to pass the user entered information. To watch the coding/designing of this form go to POST Method In Action: Simple Form

mysql_connect() is a standard function which takes 3 parameters. First parameter is host name, second parameter is the MySQL username, and the 3rd parameter is the MySQL password.
mysql_select_db() is also a php standard function. Firs parameter is the database name, with which you want the script to be connected to, and the second parameter is optional.NOTE: We can put this database connection code inside a separate file and include it inside whichever script we want using include(); or include_once(); function. This way we can reduce the coding and this helps a lot while we are editing this information.

After storing the information passed by the user inside $name and $company variables, we use the MySQL query to store this data into the database.

$sql = "INSERT into bbc values('$name','$company')";

$sql = "INSERT into bbc values('$name','$company')";

This MySQL query is stored into $sql variable and is passed to a standard PHP function for execution. i.e., mysql_query($sql);
Based on the result of the execution of the query, we show the proper messages using if statement.

mysql_error() is a standard PHP error function. This helps a lot in development stage, as it shows a descriptive error message. It is not advised to have this error function in the script at deployment stage.

show.php
If the query is executed successfully, a link to show.php file is shown and a “Successfully Inserted” message will be displayed on the browser.

thanx a lot bro..
fter watching this i will keep on following u. 😛
dear,
in show.php when u run in apache after u login u were enablle to see all every one’s company name how to make it personal i mean like
only limited access to his information
like profile.php

Thankss a lot…….plz sent me a coading page that how i fetch data from two field and how i display it on screen………plzzzzzzzzzzzzzzzzz help me……………My email id is- sudiptasaha61@yahoo.com………….plzzzzzzzzzzzzzzzzzzzz nobody can not help me about this…………….sudipta

@sudipta, Hey, you can get onto our forum and post your exact question in the relevant section. I’m sure people will be glad to help you out.

In above video tutorial, I’ve explained about fetching data from two fields. Analyze the coding and you’ll get it. I know its difficult to understand from someone else’s code, but you’ll if you put some effort.
Let me know in the forum, if you need anything more.

Hello sir, can you help me to to figure out my details.php form. i want people to see what i submitted to a website ……..like numbers by using the number to check the info. like a courier tracking number where you will see your shipping details