I'm doing a php script that writes the results of a filled out html form to a database and emails me a brief summary of what was written. I have a strange problem where it writes all the info to the DB except 2 of the MYSQL Fields are empty yet the rest carry on being filled out.
For example: If you fill out all the fields in http://www.camarosource.ca/2006_calendars/picture_submissions_2006.htm and submit, it writes the info to the DB, but leaves out the ICQ, and CITY are both BLANK.YET the brief summary emailed to me shows it in fact saved the ICQ and CITY in it's correct variables so this means it's not WRITTING them to the DB..
<?php
// create connection
$conn = mysql_connect("localhost","[PRIVATE]","[PRIVATE]")
or die(mysql_error());
// select database
$db = mysql_select_db("[PRIVATE]", $conn) or die(mysql_error());
// Set entered fields in Request Field as assigned variables
$NAME = $_POST['FULL_NAME'];
$EMAIL = $_POST['EMAIL'];
$URL = $_POST['URL'];
$ICQ = $_POST['ICQ'];
$MSN = $_POST['MSN'];
$AIM = $_POST['AIM'];
$YAHOO = $_POST['YAHOO'];
$ADDRESS = $_POST['ADDRESS'];
$CITY = $_POST['CITY'];
$PROVINCE_STATE = $_POST['PROVINCE_STATE'];
$COUNTRY = $_POST['COUNTRY'];
$POSTAL_ZIP = $_POST['POSTAL_ZIP'];
$YEAR = $_POST['CAMARO_YEAR'];
$MODEL = $_POST['CAMARO_MODEL'];
$PREFERRED_MONTH = $_POST['PREFERRED_MONTH'];
$SAID_TO_PURCHASE = $_POST['SAID_TO_PURCHASE'];
$SPECIAL_DATE = $_POST['SPECIAL_DATE'];
$CUSTOM_TITLE = $_POST['CUSTOM_TITLE'];
$PERSONALIZED_INFO = $_POST['PERSONALIZED_INFO'];
$MISSING = false;
//Start IF fields were blank
if ($NAME == "") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>Please enter your FULL NAME</b></font></p>";
}
if ($EMAIL == "") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>Please enter your EMAIL Address</b></font></p>";
}
if ($ADDRESS == "") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>Please enter your ADDRESS</b></font></p>";
}
if ($CITY == "") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>Please enter your CITY</b></font></p>";
}
if ($PROVINCE_STATE == "") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>Please enter your PROVINCE / STATE</b></font></p>";
}
if ($COUNTRY == "--- Please Select ---") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>Please select your COUNTRY</b></font></p>";
}
if ($POSTAL_ZIP == "") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>Please enter your ZIP / POSTAL CODE</b></font></p>";
}
if ($YEAR == "") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>Please enter the YEAR of your Camaro</b></font></p>";
}
if ($MODEL == "") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>Please enter the MODEL of your Camaro</b></font></p>";
}
if ($SAID_TO_PURCHASE == "--- Please Select ---") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>For Reference Purposes - Please specify how many calendars you would be interested in.</b></font></p>";
}
if ($PERSONALIZED_INFO == "") {
$MISSING = true;
echo "<p><font color=\"#FF0000\" size=\"4\"><b>Please enter your PERSONALIZED INFO.. This is what you want to have said in your Camaro Info bubble. Ie. Car specs, Mods, etc</b></font></p>";
}
if ($MISSING) exit;
// ------------------- Processing submitted data
// build our query
$query = "INSERT INTO user_submissions(FULL_NAME, EMAIL, URL, ICQ, MSN, AIM, YAHOO, ADDRESS, CITY, PROVINCE_STATE, COUNTRY, POSTAL_ZIP,
CAMARO_YEAR, CAMARO_MODEL, PREFERRED_MONTH, SAID_TO_PURCHASE, SPECIAL_DATE, CUSTOM_TITLE, PERSONALIZED_INFO, COMMENTS)
VALUES ('$NAME', '$EMAIL', '$URL', '$ICQ', '$MSN', '$AIM', '$YAHOO', '$ADDRESS', '$CITY', '$PROVINCE_STATE', '$COUNTRY', '$POSTAL_ZIP', '$CAMARO_YEAR',
'$CAMARO_MODEL', '$PREFERRED_MONTH', '$SAID_TO_PURCHASE', '$SPECIAL_DATE', '$CUSTOM_TITLE', '$PERSONALIZED_INFO', '$COMMENTS')";
// execute the query
mysql_query($query, $conn) or die (mysql_error());
submit() ;
// ------------------------------ [ Start compiling Application email to be sent to ME ] -----------------------------
function submit() {
$msg = "The following Person is interested in being in the 2006 Camarosource.ca Camaro Calendar. CHECK THE DATABASE\n\n";
$msg .= "Real Full Name : \t$_POST[FULL_NAME]\n";
$msg .= "Email Address : \t$_POST[EMAIL]\n";
$msg .= "Webpage URL : \t$_POST[URL]\n";
$msg .= "ICQ : \t$_POST[ICQ]\n";
$msg .= "CITY : \t$_POST[CITY]\n";
$msg .= "MSN : \t$_POST[MSN]\n";
$msg .= "AIM : \t$_POST[AIM]\n";
$msg .= "Yahoo! : \t$_POST[YAHOO]\n";
$msg .= "Comments : \t$_POST[COMMENTS]\n";
$mailheaders = "From: \t$_POST[EMAIL]\n";
$mailheaders .= "Reply-To: \t$_POST[EMAIL]\n\n";
mail("PRIVATE","[PRIVATE]: 2006 Camaro Calendar Submission - INFO", $msg, $mailheaders);
}
?>
I checked and the field for the ICQ and CITY ARE in fact "ICQ" "CITY" and the MYSQL database fields are also "ICQ" and "CITY".. I don't understand why it's skipping over those 2 fields and continuing to write to the rest like normally. It's like 3 fields filled in correctly, then BLANK ICQ , then 4 fields filled in correctly, then BLANK CITY, and the last 11 fields filled out correctly..