I have a form with differing inputs: text, checkbox, radio, select option.
(
All the data goes via PHP into MySQL db with no trouble EXCEPT in the case of the checkbox array.
I found information about "serialize", but i've missed some key point since it doesn't send anything into the db.
i have the db field set as ENUM, the field values have been double checked for accuracy.
then some more research and I believe that I've mixed up when to use ENUM and when to use SET. so i've switched them around. (ENUM - pick one and only one) (SET - pick one or more) Except that does not work either.
here is the form and following is the handler script.(with enum and set at the db in their original positions)
on the formhandler page, the chosen checkbox values will print with an echo command, so some part of this must be correct.
I have looked very hard for typos that would account for this; doesn't mean I didn't miss one of course!
all help and ideas appreciated.
thanks
amy
formfields:
<h6 class="altfont">Check all that apply.</h6>
<input class="formfields" type="checkbox" name="market[]" value="mfg" />Manufacturing/OEM
<input class="formfields" type="checkbox" name="market[]" value="assykit"/>Assembly/Kitting
<input class="formfields" type="checkbox" name="market[]" value="retail"/>Retail Sale
<input class="formfields" type="checkbox" name="market[]" value="firePro"/>Fire Protection
<input class="formfields" type="checkbox" name="market[]" value="energy" />Energy
<input class="formfields" type="checkbox" name="market[]" value="utility"/>Utility
<input class="formfields" type="checkbox" name="market[]" value="maint"/>Maintenance
<input class="formfields" type="checkbox" name="market[]" value="toolcrib" />Tool Crib
formhandler:
<?php
$inquiry = $_REQUEST['inquiry'];
$companyName = $_REQUEST['companyName'];
$firstName = $_REQUEST['firstName'];
$lastName = $_REQUEST['lastName'];
$officePhone = $_REQUEST['officePhone'];
$cellPhone = $_REQUEST['cellPhone'];
$email = $_REQUEST['email'];
$type = $_REQUEST['type'];
$market = serialize($_REQUEST['market']);
if (isset($_POST['submit'])) {
mysql_connect("mysql.xxxx.com","xxxxdb","xxxguest");
mysql_select_db("xxxtest_db");
$query="INSERT INTO test_table (inquiry,companyName,firstName,lastName,officePhone,cellPhone,email,type,market)";
$query.=" VALUES('$inquiry','$companyName','$firstName','$lastName','$officePhone','$cellPhone','$email','$type','$market')";
(
All the data goes via PHP into MySQL db with no trouble EXCEPT in the case of the checkbox array.
I found information about "serialize", but i've missed some key point since it doesn't send anything into the db.
i have the db field set as ENUM, the field values have been double checked for accuracy.
then some more research and I believe that I've mixed up when to use ENUM and when to use SET. so i've switched them around. (ENUM - pick one and only one) (SET - pick one or more) Except that does not work either.
here is the form and following is the handler script.(with enum and set at the db in their original positions)
on the formhandler page, the chosen checkbox values will print with an echo command, so some part of this must be correct.
I have looked very hard for typos that would account for this; doesn't mean I didn't miss one of course!
all help and ideas appreciated.
thanks
amy
formfields:
<h6 class="altfont">Check all that apply.</h6>
<input class="formfields" type="checkbox" name="market[]" value="mfg" />Manufacturing/OEM
<input class="formfields" type="checkbox" name="market[]" value="assykit"/>Assembly/Kitting
<input class="formfields" type="checkbox" name="market[]" value="retail"/>Retail Sale
<input class="formfields" type="checkbox" name="market[]" value="firePro"/>Fire Protection
<input class="formfields" type="checkbox" name="market[]" value="energy" />Energy
<input class="formfields" type="checkbox" name="market[]" value="utility"/>Utility
<input class="formfields" type="checkbox" name="market[]" value="maint"/>Maintenance
<input class="formfields" type="checkbox" name="market[]" value="toolcrib" />Tool Crib
formhandler:
<?php
$inquiry = $_REQUEST['inquiry'];
$companyName = $_REQUEST['companyName'];
$firstName = $_REQUEST['firstName'];
$lastName = $_REQUEST['lastName'];
$officePhone = $_REQUEST['officePhone'];
$cellPhone = $_REQUEST['cellPhone'];
$email = $_REQUEST['email'];
$type = $_REQUEST['type'];
$market = serialize($_REQUEST['market']);
if (isset($_POST['submit'])) {
mysql_connect("mysql.xxxx.com","xxxxdb","xxxguest");
mysql_select_db("xxxtest_db");
$query="INSERT INTO test_table (inquiry,companyName,firstName,lastName,officePhone,cellPhone,email,type,market)";
$query.=" VALUES('$inquiry','$companyName','$firstName','$lastName','$officePhone','$cellPhone','$email','$type','$market')";