• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 235
  • Last Modified:

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'));
0
andrewaiello
Asked:
andrewaiello
  • 3
  • 3
1 Solution
 
dr_dedoCommented:
can u post you form part as well ??
0
 
andrewaielloAuthor Commented:
<!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%20Settings/Eric/Desktop/styles/global.css" rel="stylesheet" type="text/css">
<link href="styles/global.css" rel="stylesheet" type="text/css"></head>

<body background="file:///C|/Documents%20and%20Settings/Eric/Desktop/back.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></div></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></div></td>
        <td bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Account
          Number</font></strong></font>
                <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></div></td>
        <td bgcolor="#0C5A39"><div align="right"><font size="4"><strong><font color="#FFFFFF" face="BankGothic Lt BT">Type
          of Establishment</font></strong></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><font 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><font size="4"><strong></strong></font></div>
        </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, &amp; 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>
0
 
dr_dedoCommented:
fields `DISTRIBUTOR_OR_SPECIALIST` and `CURRENTLY_SATISFIED`, r they string ?? or IDs ??

i see in you form
<option value="Broadline Distributor">Broadline Distributor</option>
<option value="Produce Specialist">Produce Specialist</option

unless u have DISTRIBUTOR_OR_SPECIALIST and CURRENTLY_SATISFIED as string (varchar or something) it won't insert right
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
dr_dedoCommented:
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());
0
 
andrewaielloAuthor Commented:
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.
0
 
andrewaielloAuthor Commented:
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.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now