I am trying to insert data from a text box on a form to a mysql database. The connection to the database is working, and there is a form with the field txtFirstName thats action points to the page below. I think the problem has to be the query. When the code is executed it enters a blank field into the database even when there is text in the txtFirstName text box.
I would appreciate some help.
Thanks.
<?php
// Connect To Database
$host = "db";
$user = "abc";
$password = "pword";
$db_name = "list";
// connecting to the database on battcave.com
$link = mysql_connect($host, $user, $password) or die(mysql_error());
mysql_select_db("list") or die(mysql_error());
$query = "INSERT INTO list (name) VALUES ('$_POST[$txtFirstName]')";
mysql_query($query) or die('Error, query failed');
// Insert a row of information into the table "example"
echo "Data Inserted!";
?>
I would appreciate some help.
Thanks.
<?php
// Connect To Database
$host = "db";
$user = "abc";
$password = "pword";
$db_name = "list";
// connecting to the database on battcave.com
$link = mysql_connect($host, $user, $password) or die(mysql_error());
mysql_select_db("list") or die(mysql_error());
$query = "INSERT INTO list (name) VALUES ('$_POST[$txtFirstName]')";
mysql_query($query) or die('Error, query failed');
// Insert a row of information into the table "example"
echo "Data Inserted!";
?>