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_me adow") 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[txt email]','$ _POST[txth ome_phone] ','$_POST[ txtcell_ph one]','$_P OST[txtbus ines
s_phone]','$_POST[txtaddre ss]','$_PO ST[txtcity ]','$_POST [txtstate] ','$_POST[ txtzip]',' $_POST[txt interest]' ,'$_
POST[txtquestions]') ";
//execute query
mysql_query(($query) or die('Error, query failed'));
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_me
//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]','
s_phone]','$_POST[txtaddre
POST[txtquestions]') ";
//execute query
mysql_query(($query) or die('Error, query failed'));
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I got it working now
thansk for the help
thansk for the help
Thanks for the points and the grade.
Gamebits
Gamebits
ASKER
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?