Warning there is a lot of code for me to post here.
Code: Select all
require "config.php";
$propertyname = "";
if (isset($_POST['propertyname'])) {
$propertyname = str_replace("\r\n","",$_POST['propertyname']);
$propertyname = stripslashes($propertyname);
$propertyname = mysql_real_escape_string($propertyname);
}
$date = "";
if (isset($_POST['date'])) {
$date = mysql_real_escape_string($_POST['date']);
}
$time = "";
if (isset($_POST['time'])) {
$time = mysql_real_escape_string($_POST['time']);
}
$accountname = "";
if (isset($_POST['accountname'])) {
$accountname = mysql_real_escape_string($_POST['accountname']);
}
$comments = "";
if (isset($_POST['comments'])) {
$comments = str_replace("\r\n","",$_POST['comments']);
$comments = stripslashes($comments);
}
$select1 = "";
if (isset($_POST['select1'])) {
$select1 = mysql_real_escape_string($_POST['select1']);
}
$txt1 = "";
if (isset($_POST['txt1'])) {
$txt1 = str_replace("\r\n","",$_POST['txt1']);
$txt1 = stripslashes($txt1);
}
$select2 = "";
if (isset($_POST['select2'])) {
$select2 = mysql_real_escape_string($_POST['select2']);
}
$txt2 = "";
if (isset($_POST['txt2'])) {
$txt2 = str_replace("\r\n","",$_POST['txt2']);
$txt2 = stripslashes($txt2);
}
$select3 = "";
if (isset($_POST['select3'])) {
$select3 = mysql_real_escape_string($_POST['select3']);
}
$txt3 = "";
if (isset($_POST['txt3'])) {
$txt3 = str_replace("\r\n","",$_POST['txt3']);
$txt3 = stripslashes($txt3);
}
$select4 = "";
if (isset($_POST['select4'])) {
$select4 = mysql_real_escape_string($_POST['select4']);
}
$txt4 = "";
if (isset($_POST['txt4'])) {
$txt4 = str_replace("\r\n","",$_POST['txt4']);
$txt4 = stripslashes($txt4);
}
$select5 = "";
if (isset($_POST['select5'])) {
$select5 = mysql_real_escape_string($_POST['select5']);
}
$txt5 = "";
if (isset($_POST['txt5'])) {
$txt5 = str_replace("\r\n","",$_POST['txt5']);
$txt5 = stripslashes($txt5);
}
$select6 = "";
if (isset($_POST['select6'])) {
$select6 = mysql_real_escape_string($_POST['select6']);
}
$txt6 = "";
if (isset($_POST['txt6'])) {
$txt6 = str_replace("\r\n","",$_POST['txt6']);
$txt6 = stripslashes($txt6);
}
$select7 = "";
if (isset($_POST['select7'])) {
$select7 = mysql_real_escape_string($_POST['select7']);
}
$txt7 = "";
if (isset($_POST['txt7'])) {
$txt7 = str_replace("\r\n","",$_POST['txt7']);
$txt7 = stripslashes($txt7);
}
$select8 = "";
if (isset($_POST['select8'])) {
$select8 = mysql_real_escape_string($_POST['select8']);
}
$txt8 = "";
if (isset($_POST['txt8'])) {
$txt8 = str_replace("\r\n","",$_POST['txt8']);
$txt8 = stripslashes($txt8);
}
$select9 = "";
if (isset($_POST['select9'])) {
$select9 = mysql_real_escape_string($_POST['select9']);
}
$txt9 = "";
if (isset($_POST['txt9'])) {
$txt9 = str_replace("\r\n","",$_POST['txt9']);
$txt9 = stripslashes($txt9);
}
$select10 = "";
if (isset($_POST['select10'])) {
$select10 = mysql_real_escape_string($_POST['select10']);
}
$txt10 = "";
if (isset($_POST['txt10'])) {
$txt10 = str_replace("\r\n","",$_POST['txt10']);
$txt10 = stripslashes($txt10);
}
$select11 = "";
if (isset($_POST['select11'])) {
$select11 = mysql_real_escape_string($_POST['select11']);
}
$txt11 = "";
if (isset($_POST['txt11'])) {
$txt11 = str_replace("\r\n","",$_POST['txt11']);
$txt11 = stripslashes($txt11);
}
$other1 = "";
if (isset($_POST['other1'])) {
$other1 = mysql_real_escape_string($_POST['other1']);
}
$other2 = "";
if (isset($_POST['other2'])) {
$other2 = mysql_real_escape_string($_POST['other2']);
}
$other3 = "";
if (isset($_POST['other3'])) {
$other3 = mysql_real_escape_string($_POST['other3']);
}
$other4 = "";
if (isset($_POST['other4'])) {
$other4 = mysql_real_escape_string($_POST['other4']);
}
$other5 = "";
if (isset($_POST['other5'])) {
$other5 = mysql_real_escape_string($_POST['other5']);
}
$other6 = "";
if (isset($_POST['other6'])) {
$other6 = mysql_real_escape_string($_POST['other6']);
}
$other7 = "";
if (isset($_POST['other7'])) {
$other7 = mysql_real_escape_string($_POST['other7']);
}
$other8 = "";
if (isset($_POST['other8'])) {
$other8 = mysql_real_escape_string($_POST['other8']);
}
$other9 = "";
if (isset($_POST['other9'])) {
$other9 = mysql_real_escape_string($_POST['other9']);
}
$other10 = "";
if (isset($_POST['other10'])) {
$other10 = mysql_real_escape_string($_POST['other10']);
}
$other11 = "";
if (isset($_POST['other11'])) {
$other11 = mysql_real_escape_string($_POST['other11']);
}
$arrErrors = array();
if (isset($_POST['btnsubmit'])) {
if ($propertyname == '') {
$arrErrors['propertyname'] = 'Please enter the property name.';
}
if ($time == '') {
$arrErrors['time'] = 'Please enter the time for this clearing sale.';
}
if ($accountname == '') {
$arrErrors['accountname'] = 'Please enter the account name for this clearing sale.';
}
if (($select1 == 'dozer') && ($txt1 == '')){
$arrErrors['txt1'] = 'Please enter the text for the dozer selection.';
}
if (($select1 == 'farming') && ($txt2 == '')){
$arrErrors['txt2'] = 'Please enter the text for the farming selection.';
}
if (($select1 == 'grain') && ($txt3 == '')){
$arrErrors['txt3'] = 'Please enter the text for the grain selection.';
}
if (($select1 == 'haymaking') && ($txt4 == '')){
$arrErrors['txt4'] = 'Please enter the text for the haymaking selection.';
}
if (($select1 == 'vehicles') && ($txt5 == '')){
$arrErrors['txt5'] = 'Please enter the text for the vehicles selection.';
}
if (($select1 == 'tools') && ($txt6 == '')){
$arrErrors['txt6'] = 'Please enter the text for the tools selection.';
}
if (($select1 == 'household') && ($txt7 == '')){
$arrErrors['txt7'] = 'Please enter the text for the household selection.';
}
if (($select1 == 'livestock') && ($txt8 == '')){
$arrErrors['txt8'] = 'Please enter the text for the livestock selection.';
}
if (($select1 == 'number') && ($txt9 == '')){
$arrErrors['txt9'] = 'Please enter the text for the number selection.';
}
if (($select1 == 'refreshments') && ($txt10 == '')){
$arrErrors['txt10'] = 'Please enter the text for the refreshments selection.';
}
if (($select1 == 'direction') && ($txt11 == '')){
$arrErrors['txt11'] = 'Please enter the text for the direction selection.';
}
if (($select1 == 'other') && ($txt12 == '')){
$arrErrors['txt12'] = 'Please enter the text for the other selection.';
}
if (($_POST['select1'] == 'other') && ($_POST['other1'] == '')) {
$arrErrors['other1'] = 'Please enter a category in the other text box number 1.';
}
if (($_POST['select2'] == 'other') && ($_POST['other2'] == '')) {
$arrErrors['other2'] = 'Please enter a category in the other text box number 2.';
}
if (($_POST['select3'] == 'other') && ($_POST['other3'] == '')) {
$arrErrors['other3'] = 'Please enter a category in the other text box number 3.';
}
if (($_POST['select4'] == 'other') && ($_POST['other4'] == '')) {
$arrErrors['other4'] = 'Please enter a category in the other text box number 4.';
}
if (($_POST['select5'] == 'other') && ($_POST['other5'] == '')) {
$arrErrors['other5'] = 'Please enter a category in the other text box number 5.';
}
if (($_POST['select6'] == 'other') && ($_POST['other6'] == '')) {
$arrErrors['other6'] = 'Please enter a category in the other text box number 6.';
}
if (($_POST['select7'] == 'other') && ($_POST['other7'] == '')) {
$arrErrors['other7'] = 'Please enter a category in the other text box number 7.';
}
if (($_POST['select8'] == 'other') && ($_POST['other8'] == '')) {
$arrErrors['other8'] = 'Please enter a category in the other text box number 8.';
}
if (($_POST['select9'] == 'other') && ($_POST['other9'] == '')) {
$arrErrors['other9'] = 'Please enter a category in the other text box number 9.';
}
if (($_POST['select10'] == 'other') && ($_POST['other10'] == '')) {
$arrErrors['other10'] = 'Please enter a category in the other text box number 10.';
}
if (($_POST['select11'] == 'other') && ($_POST['other11'] == '')) {
$arrErrors['other11'] = 'Please enter a category in the other text box number 11.';
}
if (count($arrErrors) == 0) {
if ($other1 != "") {
$select1 = $other1;
} else {
$select1 = $select1;
}
if ($other2 != "") {
$select2 = $other2;
} else {
$select2 = $select2;
}
if ($other3 != "") {
$select3 = $other3;
} else {
$select3 = $select3;
}
if ($other4 != "") {
$select4 = $other4;
} else {
$select4 = $select4;
}
if ($other5 != "") {
$select5 = $other5;
} else {
$select5 = $select5;
}
if ($other6 != "") {
$select6 = $other6;
} else {
$select6 = $select6;
}
if ($other7 != "") {
$select7 = $other7;
} else {
$select7 = $select7;
}
if ($other8 != "") {
$select8 = $other8;
} else {
$select8 = $select8;
}
if ($other9 != "") {
$select9 = $other9;
} else {
$select9 = $select9;
}
if ($other10 != "") {
$select10 = $other10;
} else {
$select10 = $select10;
}
if ($other11 != "") {
$select11 = $other11;
} else {
$select11 = $select11;
}
$insert = "INSERT INTO `clearingsales` (`date`, `propertyname`, `time`, `accountname`, `comments`, `select1`, `txt1`, `select2`, `txt2`, `select3`, `txt3`, `select4`, `txt4`, `select5`, `txt5`, `select6`, `txt6`, `select7`, `txt7`, `select8`, `txt8`, `select9`, `txt9`, `select10`, `txt10`, `select11`, `txt11`)
VALUES ('$date', '$propertyname', '$time', '$accountname', '$comments', '$select1', '$txt1', '$select2', '$txt2', '$select3', '$txt3', '$select4', '$txt4', '$select5', '$txt5', '$select6', '$txt6', '$select7', '$txt7', '$select8', '$txt8', '$select9', '$txt9', '$select10', '$txt10', '$select11', '$txt11')";
if (mysql_query ($insert)) {
$query = mysql_query("SELECT * FROM `clearingsales` WHERE `propertyname` = '$propertyname'") or die ("Could not query because: ".mysql_error());
$row = mysql_fetch_assoc($query);
$insertID = mysql_insert_id();
header ("Location: clearing_sale_added.php?id=".$insertID);
} else {
print "<p>Could not add the entry because: <b>" . mysql_error() . "</b>. The query was $insert.</p>";
}
} else {
// The error array had something in it. There was an error.
// Start adding error text to an error string.
$strError = '<div class="formerror"><p>Please check the following and try again:</p><ul>';
// Get each error and add it to the error string
// as a list item.
foreach ($arrErrors as $error) {
$strError .= "<li>$error</li>";
}
$strError .= '</ul></div>';
}
}