Hello,
I am trying to capture some checkbox information and have it insert
into a mysql database. Here what i have so far. I created the form. I
have it going the the php processing page / thank you page which is
inserting the information into a database.
when i test the result i am getting "/0" in the mol part number columns
=======form page: Promo Order Form ================================
<form action="mail-promo1.php" method="post"
enctype="multipart/form-data">
// form field regular text field
<input name="company_name" type="text" id="company_name" size="45"
maxlength="80" onKeyPress="return handleEnter(this, event)"
onKeyUp="highlight(event)" onClick="highlight(event)">
// checkbox field
<input type="checkbox" name="check[]" value="MOL2400" checked/>
<input type="checkbox" name="check[]" value="MOL2315" checked/>
<input type="checkbox" name="check[]" value="MOL2850" />
<input type="submit" name="Submit" value="Submit">
======processing page: thank you page =============================
$db_host = "localhost";
$db_name = "sample_request";
$db_user = "user";
$db_pass = "pass";
$company = "company"; // MUST EDIT
$company_email="email address"; // MUST EDIT
$URL="domain.com"; // MUST EDIT
$recipient = "$company_email" ;
$subject = "$company Promo Order Form";
$autoresponder_subject = "$company Promo Order Confirmation Receipt";
$required = "";
$company_name = isset($_POST['company_name']) ? $_POST['company_name']
: '';
foreach($_POST['check'] as $value) {
$check_msg .= "Checked: $value\n";
}
// if the subject option is not set: set the default
if (!$subject)
$subject = "$company Promo Order information request form";
$new_content = "Below is the result of your feedback form. It was
submitted by\n";
$new_content .= "($email) on ".date("l, F j, Y \a\t H:i:s")."\n"; //
email shows a instead of at
$new_content .=
"---------------------------------------------------------------------------\n\n";
$new_content .= " Company: $company_name\n
Checked Options:\n
$check_msg\n
End of Form\r\n\r\n";
// if the redirect option is set: redirect them
if ($redirect) {
header ("Location: $redirect");
exit;
} else {
?>
<P>
<H4>Thank you for submitting your Promo Order Form <? echo
$name;?></H4>
</P>
<P>
Team <? echo $company;?> is looking forward to serving you.
</P>
// <---------- save to database ----------> //
function save_userinfo(){
global $db_host, $db_name, $db_user, $db_pass;
global $company_name;
$company_name = mysql_escape_string( trim ($company_name) );
if ($db = @mysql_connect( $db_host, $db_user, $db_pass )) {
if ($db){
if ( mysql_select_db($db_name, $db) ){
$query = "INSERT INTO `promo` (
`id` , `company_name` , `MOL2400` , `MOL2315` , ` `MOL2850`)
VALUES (
NULL , '$company_name', '$MOL2400' , '$MOL2315' , '$MOL2850'
);";
mysql_query($query , $db);
mysql_close($db);
}
}
} else {
echo "Not connected to Database!";
====== promo database ============================================
id, int(11), auto_increment, primary
company_name, varchar (255), NULL YES, NULL
MOL2400, binary (1), null yes, default 0
MOL2315, binary (1), null yes, default 0
MOL2850, binary (1), null yes, default 0
===================================================================
thanks for the help
rick