Link to home
Start Free TrialLog in
Avatar of andrewaiello
andrewaiello

asked on

form data not being inserted into database

I am trying to insert form data into a mysql database.  Below is the code for the handle php page i am using.  when i submit the form there are no errors but when i query the database the table is empty.


How do i get the fields below into my database?

//declare text boxes as variables

$name = '$_POST[txtname]';
$email = '$_POST[txtemail]';
$home_phone = '$_POST[txthome_phone]';
$cell_phone = '$_POST[txtcell_phone]';
$business_phone = '$_POST[txtbusiness_phone]';
$address = '$_POST[txtaddress]';
$city = '$_POST[txtcity]';
$state = '$_POST[txtstate]';
$zip = '$_POST[txtzip]';
$interest = '$_POST[txtinterest]';
$questions = '$_POST[txtquestions]';


//Linking to the database on pair.com

$link = mysql_connect($host, $user, $password) or die (mysql_error());
Mysql_select_db("motion_meadow") or die(mysql_error());


//Insert text box values from form into the database
$query = "INSERT INTO form_data(NAME, EMAIL, HOME_PHONE, CELL_PHONE, BUSINESS_PHONE, ADDRESS, CITY, STATE,

ZIP, AREA_OF_INTEREST, QUESTIONS_COMMENTS, HOW_DID_YOU_HEAR_ABOUT_US)

VALUES('$_POST[txtname]','$_POST[txtemail]','$_POST[txthome_phone]','$_POST[txtcell_phone]','$_POST[txtbusines

s_phone]','$_POST[txtaddress]','$_POST[txtcity]','$_POST[txtstate]','$_POST[txtzip]','$_POST[txtinterest]','$_

POST[txtquestions]') ";


//execute query
mysql_query(($query) or die('Error, query failed'));
ASKER CERTIFIED SOLUTION
Avatar of gamebits
gamebits
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andrewaiello
andrewaiello

ASKER

OK, now there is data being inserted but its not the text box values.  The actual variable is being inserted.

The database is showing $_POST[txtname] $_POST[txtemail]......

How do i get the value that the user puts into the form to go into the db?
I got it working now

thansk for the help
Thanks for the points and the grade.

Gamebits