andrewaiello
asked on
post list box to database
When i execute the query below all the data is inserted into my db except for the two list boxes. Is there something else i need to do to make the list box values go into the database?
$name = 'txtname';
$email = 'txtemail';
$company = 'txtcompany';
$phone = 'txtphone';
$account_number = 'txtaccount';
$type = 'txttype';
$listboxONE = 'list1';
$listboxTWO = 'list2';
//Linking to the database on pair.com
$link = mysql_connect($host, $user, $password) or die (mysql_error());
Mysql_select_db("mot") or die(mysql_error());
//Insert text box values from form into the database
$query = mysql_query("INSERT INTO form_data (`NAME`, `EMAIL`, `COMPANY`, `PHONE`, `ACCOUNT_NUMBER`, `TYPE_OF_ESTABLISHMENT`, `DISTRIBUTOR_OR_SPECIALIST `, `CURRENTLY_SATISFIED`) VALUES ('$_POST[$name]', '$_POST[$email]', '$_POST[$company]', '$_POST[$phone]', '$_POST[$account_number]', '$_POST[$type]', '$_POST[$listboxONE]', '$_POST[$listboxTWO]')");
//execute query
mysql_query(($query) or die('Error, query failed'));
$name = 'txtname';
$email = 'txtemail';
$company = 'txtcompany';
$phone = 'txtphone';
$account_number = 'txtaccount';
$type = 'txttype';
$listboxONE = 'list1';
$listboxTWO = 'list2';
//Linking to the database on pair.com
$link = mysql_connect($host, $user, $password) or die (mysql_error());
Mysql_select_db("mot") or die(mysql_error());
//Insert text box values from form into the database
$query = mysql_query("INSERT INTO form_data (`NAME`, `EMAIL`, `COMPANY`, `PHONE`, `ACCOUNT_NUMBER`, `TYPE_OF_ESTABLISHMENT`, `DISTRIBUTOR_OR_SPECIALIST
//execute query
mysql_query(($query) or die('Error, query failed'));
can u post you form part as well ??
ASKER
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>CONTEST</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="file:///C|/Documents %20and%20S ettings/Er ic/Desktop /styles/gl obal.css" rel="stylesheet" type="text/css">
<link href="styles/global.css" rel="stylesheet" type="text/css"></head>
<body background="file:///C|/Doc uments%20a nd%20Setti ngs/Eric/D esktop/bac k.gif" topmargin="0">
<div align="center"><br>
<font color="#666666" size="2" face="Arial, Helvetica, sans-serif">[all information
below is required for eligibility]</font></div>
<form name="form1" method="post" action="sweeps_form_handle .php">
<div align="center">
<table width="1264" cellpadding="4" cellspacing="3">
<tr>
<td width="648" height="53" bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Name
<input name="txtname" type="text" class="inputField" size="20" height="40">
</font></strong></font></d iv></td>
<td width="589" bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Phone</font></strong>< /font>
<input name="txtphone" type="text" class="inputField" size="20">
</div></td>
</tr>
<tr>
<td bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Email
<input name="txtemail" type="text" class="inputField" size="20">
</font></strong></font></d iv></td>
<td bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Account
Number</font></strong></fo nt>
<input name="txtaccount" type="text" class="inputField" size="20">
</div></td>
</tr>
<tr>
<td bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Company
<input name="txtcompany" type="text" class="inputField" size="20">
</font></strong></font></d iv></td>
<td bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Type
of Establishment</font></stro ng></font>
<input name="txttype" type="text" class="inputField" size="20">
</div></td>
</tr>
<tr bgcolor="#3F6087">
<td align="right" bgcolor="#0C5A39"><div align="center">
<table width="648" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="648" height="43"><div align="right"><strong><fon t color="#FFFFFF" size="4" face="BankGothic Lt BT">Where do you currently purchase your produce? </font></strong></div>
<div align="right"></div></td>
</tr>
</table>
<div align="right"><font size="4"><strong><font color="#000000" face="BankGothic Lt BT">
<select name="list1" size="2" class="inputField" id="txtquestion">
<option value="Broadline Distributor">Broadline Distributor</option>
<option value="Produce Specialist">Produce Specialist</option>
</select>
</font></strong></font><fo nt size="4"><strong></strong> </font></d iv>
</div></td>
<td bgcolor="#0C5A39"><div align="center">
<table width="589" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="589"><div align="center"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">are you satisfied with the pricing, quality, & food safety that your produce distributor provides?</font></strong>< /font> <br>
</div>
<div align="center">
<select name="list2" size="2" class="inputField" id="txtquestiontwo">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
</div></td>
</tr>
</table>
</div></td>
</tr>
<tr bgcolor="#BFFFCF">
<td height="48" colspan="2" bgcolor="#ACE6D2"><div align="center"><font size="4"><strong>
<input type="image" src="images/submit.gif" value="Submit"
alt="Submit now" name="Submit">
</strong></font></div></td >
</tr>
</table>
</div>
</form>
</body>
</html>
<html>
<head>
<title>CONTEST</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="file:///C|/Documents
<link href="styles/global.css" rel="stylesheet" type="text/css"></head>
<body background="file:///C|/Doc
<div align="center"><br>
<font color="#666666" size="2" face="Arial, Helvetica, sans-serif">[all information
below is required for eligibility]</font></div>
<form name="form1" method="post" action="sweeps_form_handle
<div align="center">
<table width="1264" cellpadding="4" cellspacing="3">
<tr>
<td width="648" height="53" bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Name
<input name="txtname" type="text" class="inputField" size="20" height="40">
</font></strong></font></d
<td width="589" bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Phone</font></strong><
<input name="txtphone" type="text" class="inputField" size="20">
</div></td>
</tr>
<tr>
<td bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Email
<input name="txtemail" type="text" class="inputField" size="20">
</font></strong></font></d
<td bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Account
Number</font></strong></fo
<input name="txtaccount" type="text" class="inputField" size="20">
</div></td>
</tr>
<tr>
<td bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Company
<input name="txtcompany" type="text" class="inputField" size="20">
</font></strong></font></d
<td bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Type
of Establishment</font></stro
<input name="txttype" type="text" class="inputField" size="20">
</div></td>
</tr>
<tr bgcolor="#3F6087">
<td align="right" bgcolor="#0C5A39"><div align="center">
<table width="648" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="648" height="43"><div align="right"><strong><fon
<div align="right"></div></td>
</tr>
</table>
<div align="right"><font size="4"><strong><font color="#000000" face="BankGothic Lt BT">
<select name="list1" size="2" class="inputField" id="txtquestion">
<option value="Broadline Distributor">Broadline Distributor</option>
<option value="Produce Specialist">Produce Specialist</option>
</select>
</font></strong></font><fo
</div></td>
<td bgcolor="#0C5A39"><div align="center">
<table width="589" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="589"><div align="center"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">are you satisfied with the pricing, quality, & food safety that your produce distributor provides?</font></strong><
</div>
<div align="center">
<select name="list2" size="2" class="inputField" id="txtquestiontwo">
<option value="No">No</option>
<option value="Yes">Yes</option>
</select>
</div></td>
</tr>
</table>
</div></td>
</tr>
<tr bgcolor="#BFFFCF">
<td height="48" colspan="2" bgcolor="#ACE6D2"><div align="center"><font size="4"><strong>
<input type="image" src="images/submit.gif" value="Submit"
alt="Submit now" name="Submit">
</strong></font></div></td
</tr>
</table>
</div>
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
have just noticed that
Mysql_select_db("mot") or die(mysql_error());
^
it has a capital M
should be
mysql_select_db("mot") or die(mysql_error());
Mysql_select_db("mot") or die(mysql_error());
^
it has a capital M
should be
mysql_select_db("mot") or die(mysql_error());
ASKER
actually the capital M had no effect on the query. It is working with it, but I will change it to m just to be consistent.
Thanks for pointing that out.
Thanks for pointing that out.
ASKER
FYI
I just forgot to change the id field in the form. I've been working with php so much in the past few days, i did not focus enough on the html part of it.
I just forgot to change the id field in the form. I've been working with php so much in the past few days, i did not focus enough on the html part of it.