Click to See Complete Forum and Search --> : sending data from form to database


john_zakaria
10-21-2008, 07:55 AM
hi everyone plz i want to know the steps of how to store data from a form to the data base .
i know the mysql query but i dont know how to get data from the form and store it in my data base in phpmyadmin??
i have a table in db and i want to store data in it from the form disaplyed in intenert explorer
what are the steps of storing it and displaying it to the forum again and what are the functions used to do this??

xvszero
10-21-2008, 02:31 PM
I don't know anything about phpmyadmin but doing it in straight php is easy.

Connect to your database...

$dbhost = 'localhost';
$dbuser = 'username';
$dbpw = 'password';
$dbname = 'database namet';

$connection = mysql_connect($dbhost, $dbuser, $dbpw)
or die("Unable to connect to MySQL");

mysql_select_db($dbname) or die
('Could not select database');

Get your data from your form...

$data = $_REQUEST['data'];
$data2 = $_REQUEST['data2'];

And then put it in the database...

$query = "INSERT INTO tablename (columnname1, columnname2) VALUES ('$data1', '$data2')";
$result = mysql_query($query);