There are two forms and the first form sends the data no matter what and I need to send the data for form2 only if the field "vehicle_rebuild_status" has a value of "Yes" The form works fine and puts the data in both tables if I don't define anything, It's when I try to put the if ("vehicle_rebuild_status" = yes) is where the problems start. It's half way down the page LINE 417. I mark Line 417 Please Help
NO ERRORS but sends into both ---- if ($_POST ["vehicle_rebuild_status"] = "Car Sold")
CODE
<?php
/* BEGIN - SECTION 1 */
//require_once(dirname(__FILE__) . "/../../FORMfields.php");
require_once($_SERVER["DOCUMENT_ROOT"] . "/FORMfields/FORMfields.php"); // Absolute path
//$GLOBALS["FF_GLOBALS_VERBOSE"] = true; // For debugging purposes
//$GLOBALS["FF_GLOBALS_SEND_EMAILS"] = false; // For debugging purposes
// ---------- FORM PROPERTIES - START ----------
// NOTE: Only changes made to the form properties and structure
// (not actions) of the form can be reloaded into FORMgen.
define ("Rebuild", "vehicle_rebuild_status");
define("FF_SLEEP", 4);
define("FF_FORM_NAME", "vehicles");
define("FF_FORM_TITLE", htmlspecialchars("Vehicle Imput"));
define("FF_STYLE_FILE", FF_ROOT_URL . "/styles/defaultRightLabels.css");
define("FF_SHOW_W3C_VALIDATOR", false);
define("FF_DISPLAY_CONFIRMATION", true); // Note: Static form layout is not compatible with the confirmation screen.
define("FF_DISPLAY_THANK_YOU_PAGE", true);
define("FF_INSERT_INTO_DB", true);
define("FF_SEND_FORM_EMAIL1", false);
define("FF_FORM_EMAIL1_TO", "");
define("FF_FORM_EMAIL1_TO_FIELDS", "");
define("FF_FORM_EMAIL1_FROM", ""); // Note: You cannot specify a FF_FORM_EMAIL1_FROM and FF_FORM_EMAIL1_FROM_FIELD!
define("FF_FORM_EMAIL1_FROM_FIELD", "");
define("FF_FORM_EMAIL1_SUBJECT", "Vehicle's Submission");
define("FF_FORM_EMAIL1_MESSAGE_HEADER", "");
define("FF_FORM_EMAIL1_MESSAGE_FOOTER", "");
define("FF_FORM_EMAIL1_USE_HTML", true);
define("FF_FORM_EMAIL1_SEND_FORM_DATA", false);
define("FF_SEND_FORM_EMAIL2", false);
define("FF_FORM_EMAIL2_TO", "");
define("FF_FORM_EMAIL2_TO_FIELDS", "");
define("FF_FORM_EMAIL2_FROM", ""); // Note: You cannot specify both a FF_FORM_EMAIL2_FROM and FF_FORM_EMAIL2_FROM_FIELD!
define("FF_FORM_EMAIL2_FROM_FIELD", "");
define("FF_FORM_EMAIL2_SUBJECT", "Vehicle's Submission");
define("FF_FORM_EMAIL2_MESSAGE_HEADER", "");
define("FF_FORM_EMAIL2_MESSAGE_FOOTER", "");
define("FF_FORM_EMAIL2_USE_HTML", true);
define("FF_FORM_EMAIL2_SEND_FORM_DATA", false);
$GLOBALS["FF_CANCEL_URL"] = "/";
$GLOBALS["FF_DONE_URL"] = "/";
$GLOBALS["FF_DEFAULTS"] = array(
);
// ---------- FORM PROPERTIES - END ----------
// ---------- FORM STRUCTURE - START ----------
$ffForm = new FfForm();
$ffForm->addField(new DateField("vehicle_date", "Date", FORM_FIELD_REQUIRED, " ", "2006-01-01", "2018-12-31"));
$ffForm->formFields["vehicle_date"]->setHelp("The date the vehicle was brought in");
$ffForm->addField(new TextField("vehicle_co_number", "Co Number", FORM_FIELD_REQUIRED, 255, 1, null));
$ffForm->formFields["vehicle_co_number"]->setHelp("This is the Co number of the vehicle");
$ffForm->addField(new YearField("vehicle_year", "Year", FORM_FIELD_REQUIRED, " ", null, 1970, 2020));
$ffForm->formFields["vehicle_year"]->setHelp("This is the year of the vehicle");
$ffForm->addField(new TextField("vehicle_make", "Make", FORM_FIELD_REQUIRED, 255, 1, null));
$ffForm->formFields["vehicle_make"]->setHelp("This is the make of the vehicle");
$ffForm->addField(new TextField("vehicle_model", "Model", FORM_FIELD_REQUIRED, 255, 1, null));
$ffForm->formFields["vehicle_model"]->setHelp("This is the model of the vehicle");
$ffForm->addField(new TextField("vehicle_vin", "Vin", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm->formFields["vehicle_vin"]->setHelp("This is the Vin of the vehicle");
$ffForm->addField(new TextField("vehicle_color", "Color", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm->formFields["vehicle_color"]->setHelp("This is the color of the vehicle");
$ffForm->addField(new TextField("vehicle_miles", "Miles", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm->formFields["vehicle_miles"]->setHelp("This is the miles of the vehicle");
$ffForm->addField(new TextField("vehicle_location", "Location", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm->formFields["vehicle_location"]->setHelp("This is where the vehicle was bought");
$ffForm->addField(new TextField("vehicle_driver", "Driver", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm->formFields["vehicle_driver"]->setHelp("This is the driver that delivered the vehicle");
$ffForm->addField(new DropDownField("vehicle_title", "Title", FORM_FIELD_NOT_REQUIRED, array("Clean","Rebuild"), null, "[Select One]", "on"));
$ffForm->formFields["vehicle_title"]->setHelp("This is the kind of title the vehicle has");
$ffForm->addField(new TextAreaField("vehicle_info", "Extra Info", FORM_FIELD_NOT_REQUIRED, 255, 1, 10, 50));
$ffForm->formFields["vehicle_info"]->setHelp("This is for any extra Info");
$ffForm->addField(new DropDownField("vehicle_rebuild_status", "Rebuild", FORM_FIELD_NOT_REQUIRED, array("Yes","No","Maybe"), null, "[Select One]", "on"));
$ffForm->formFields["vehicle_rebuild_status"]->setHelp("Is this a rebuildable");
$ffForm2 = new FfForm();
$ffForm2->addField(new DateField("vehicle_date", "Date", FORM_FIELD_REQUIRED, " ", "2006-01-01", "2018-12-31"));
$ffForm2->formFields["vehicle_date"]->setHelp("The date the vehicle was brought in");
$ffForm2->addField(new TextField("vehicle_co_number", "Co Number", FORM_FIELD_REQUIRED, 255, 1, null));
$ffForm2->formFields["vehicle_co_number"]->setHelp("This is the Co number of the vehicle");
$ffForm2->addField(new TextField("pool_number", "Pool Number", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm2->formFields["pool_number"]->setHelp("This is where the pool number goes");
$ffForm2->addField(new YearField("vehicle_year", "Year", FORM_FIELD_REQUIRED, " ", null, 1970, 2020));
$ffForm2->formFields["vehicle_year"]->setHelp("This is the year of the vehicle");
$ffForm2->addField(new TextField("vehicle_make", "Make", FORM_FIELD_REQUIRED, 255, 1, null));
$ffForm2->formFields["vehicle_make"]->setHelp("This is the make of the vehicle");
$ffForm2->addField(new TextField("vehicle_model", "Model", FORM_FIELD_REQUIRED, 255, 1, null));
$ffForm2->formFields["vehicle_model"]->setHelp("This is the model of the vehicle");
$ffForm2->addField(new TextField("vehicle_vin", "Vin", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm2->formFields["vehicle_vin"]->setHelp("This is the Vin of the vehicle");
$ffForm2->addField(new TextField("vehicle_color", "Color", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm2->formFields["vehicle_color"]->setHelp("This is the color of the vehicle");
$ffForm2->addField(new TextField("vehicle_miles", "Miles", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm2->formFields["vehicle_miles"]->setHelp("This is the miles of the vehicle");
$ffForm2->addField(new TextField("vehicle_location", "Location", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm2->formFields["vehicle_location"]->setHelp("This is where the vehicle was bought");
$ffForm2->addField(new TextField("vehicle_driver", "Driver", FORM_FIELD_NOT_REQUIRED, 255, 1, null));
$ffForm2->formFields["vehicle_driver"]->setHelp("This is the driver that delivered the vehicle");
$ffForm2->addField(new DropDownField("vehicle_title", "Title", FORM_FIELD_NOT_REQUIRED, array("Clean","Rebuild"), null, "[Select One]", "on"));
$ffForm2->formFields["vehicle_title"]->setHelp("This is the kind of title the vehicle has");
$ffForm2->addField(new TextAreaField("vehicle_info", "Extra Info", FORM_FIELD_NOT_REQUIRED, 255, 1, 10, 50));
$ffForm2->formFields["vehicle_info"]->setHelp("This is for any extra Info");
$ffForm2->addField(new DropDownField("vehicle_rebuild_status", "Rebuild", FORM_FIELD_NOT_REQUIRED, array("Yes","No","Maybe"), null, "[Select One]", "on"));
$ffForm2->formFields["vehicle_rebuild_status"]->setHelp("Is this a rebuildable");
$ffForm = new FfForm();
$ffForm->addFields($ffForm);
$ffForm->addFields($ffForm2);
$ffForm->addField(new SubmitField("ff_submit", "Submit"));
$ffForm->addField(new SubmitField("ff_clear", "Clear"));
$ffForm->addField(new SubmitField("ff_cancel", "Cancel"));
// ---------- FORM STRUCTURE - END ----------
// ---------- FORM ACTIONS - START ----------
class SubmitButtonListener extends FfButtonListener
{
function onClick(&$ffForm)
{
if ($ffForm->checkValues()) {
// CONFIRMATION OPERATION:
$ffForm->setEditable(false);
$ffForm->setEditableFields(array("ff_back", "ff_confirm"), true);
$ffForm->setHiddenFields(array("ff_back", "ff_confirm"), false);
$GLOBALS["action"] = FF_CONFIRM;
}
}
}
class ConfirmButtonListener extends FfButtonListener
{
function onClick(&$ffForm)
{
//echo "CONFIRM<hr/>";
if ($ffForm->checkValues()) {
// SUBMIT OPERATION:
$GLOBALS["action"] = FF_DONE;
// Send an email?
if (FF_SEND_FORM_EMAIL1)
{
$formEmail1To = FF_FORM_EMAIL1_TO;
// Add the to addresses which were entered by the user
$formEmail1ToFields = split(",", FF_FORM_EMAIL1_TO_FIELDS);
foreach($formEmail1ToFields as $fieldName) {
if (!empty($fieldName))
$formEmail1To .= "," . $ffForm->getValue($fieldName);
}
// Was the address specified or are we loading from a field name?
$formEmail1From = FF_FORM_EMAIL1_FROM;
if (!FormField::isBlank(FF_FORM_EMAIL1_FROM_FIELD)) {
$formEmail1From = $ffForm->getValue(FF_FORM_EMAIL1_FROM_FIELD);
}
$formEmail1Cc = null;
$formEmail1Bcc = null;
$formEmail1Subject = FF_FORM_EMAIL1_SUBJECT;
$formEmail1MsgHeader = FF_FORM_EMAIL1_MESSAGE_HEADER; // The text that preceeds the field values
$formEmail1MsgFooter = FF_FORM_EMAIL1_MESSAGE_FOOTER; // The text that follows the field values
$formEmail1CssFile = null; // If you don't like the defaulted CSS styles, you can include another style sheet.
$formEmail1UseHtml = FF_FORM_EMAIL1_USE_HTML; // Use false for text emails
$formEmail1SendFormData = FF_FORM_EMAIL1_SEND_FORM_DATA; // Use false to not send form data
$formEmail1SendFormUploads = true; // Use false to not attach files uploaded from the form
if (!$formEmail1UseHtml) { // Convert the line of text to multiple lines?
$formEmail1MsgHeader = str_replace("<br/>", "\n", $formEmail1MsgHeader);
$formEmail1MsgFooter = str_replace("<br/>", "\n", $formEmail1MsgFooter);
}
// You can include extra attachments by populating an array as follows.
// Note: All UploadFields are automatically attached to the email.
$formEmail1Attachments = null;
//$formEmail1Attachments[0] = array(dirname(__FILE__) . "/../calendar.gif", "calendar.gif");
$ffForm->email($formEmail1To, $formEmail1Subject, $formEmail1From,
$formEmail1Cc, $formEmail1Bcc, $formEmail1MsgHeader,
$formEmail1MsgFooter, $formEmail1Attachments, $formEmail1UseHtml,
$formEmail1CssFile, $formEmail1SendFormData, $formEmail1SendFormUploads);
}
// Send a second email?
if (FF_SEND_FORM_EMAIL2)
{
$formEmail2To = FF_FORM_EMAIL2_TO;
// Add the to addresses which were entered by the user
$formEmail2ToFields = split(",", FF_FORM_EMAIL2_TO_FIELDS);
foreach($formEmail2ToFields as $fieldName) {
if (!empty($fieldName))
$formEmail2To .= "," . $ffForm->getValue($fieldName);
}
$formEmail2From = FF_FORM_EMAIL2_FROM;
if (!FormField::isBlank(FF_FORM_EMAIL2_FROM_FIELD)) {
$formEmail2From = $ffForm->getValue(FF_FORM_EMAIL2_FROM_FIELD);
}
$formEmail2Cc = null;
$formEmail2Bcc = null;
$formEmail2Subject = FF_FORM_EMAIL2_SUBJECT;
$formEmail2MsgHeader = FF_FORM_EMAIL2_MESSAGE_HEADER; // The text that preceeds the field values
$formEmail2MsgFooter = FF_FORM_EMAIL2_MESSAGE_FOOTER; // The text that follows the field values
$formEmail2CssFile = null; // If you don't like the defaulted CSS styles, you can include another style sheet.
$formEmail2UseHtml = FF_FORM_EMAIL2_USE_HTML; // Use false for text emails
$formEmail2SendFormData = FF_FORM_EMAIL2_SEND_FORM_DATA; // Use false to not send form data
$formEmail2SendFormUploads = true; // Use false to not attach files uploaded from the form
if (!$formEmail2UseHtml) { // Convert the line of text to multiple lines?
$formEmail2MsgHeader = str_replace("<br/>", "\n", $formEmail2MsgHeader);
$formEmail2MsgFooter = str_replace("<br/>", "\n", $formEmail2MsgFooter);
}
// You can include extra attachments by populating an array as follows.
// Note: All UploadFields are automatically attached to the email.
$formEmail2Attachments = null;
//$formEmail2Attachments[0] = array(dirname(__FILE__) . "/../calendar.gif", "calendar.gif");
$ffForm->email($formEmail2To, $formEmail2Subject, $formEmail2From,
$formEmail2Cc, $formEmail2Bcc, $formEmail2MsgHeader,
$formEmail2MsgFooter, $formEmail2Attachments, $formEmail2UseHtml,
$formEmail2CssFile, $formEmail2SendFormData, $formEmail2SendFormUploads);
}
if (FF_INSERT_INTO_DB) {
global $ffForm;
$ffForm->getParameters();
$ffForm->addField(new DateTimeField("ff_inserted_on", "Inserted On", FORM_FIELD_REQUIRED, null));
$ffForm->formFields["ff_inserted_on"]->getCurrentDateTime();
$ffForm->insertValuesIntoDb(FF_FORM_NAME);}
Line 417---- if ****This is where I need help****
global $ffForm2;
$ffForm2->getParameters();
$ffForm2->addField(new DateTimeField("ff_inserted_on", "Inserted On", FORM_FIELD_REQUIRED, null));
$ffForm2->formFields["ff_inserted_on"]->getCurrentDateTime();
$ffDb = &FfDb::s();
$ffForm2->addField(new HiddenField("ff_id", $ffDb->getSimpleValue("SELECT LAST_INSERT_ID()")));
$ffForm2->insertValuesIntoDb("rebuilds");
}
if (!FF_DISPLAY_THANK_YOU_PAGE) {
header("Location: " . $GLOBALS["FF_DONE_URL"]);
}
}
}
}
if ($ffForm->fieldExists("ff_submit")) {
// Does the submit button submit the data or confirm the data?
if (FF_DISPLAY_CONFIRMATION)
$ffForm->formFields["ff_submit"]->addButtonListener(new SubmitButtonListener());
else
$ffForm->formFields["ff_submit"]->addButtonListener(new ConfirmButtonListener());
}
if ($ffForm->fieldExists("ff_clear")) {
$ffForm->formFields["ff_clear"]->addButtonListener(new FfClearButtonListener());
}
class CancelButtonListener extends FfButtonListener
{
function onClick(&$ffForm)
{
// CANCEL OPERATION:
header("Location: " . $GLOBALS["FF_CANCEL_URL"]);
}
}
if ($ffForm->fieldExists("ff_cancel")) {
$ffForm->formFields["ff_cancel"]->addButtonListener(new CancelButtonListener());
}
$ffForm->addField(new SubmitField("ff_back", "<" . FfLH::t("Back")));
$confirmButton = new SubmitField("ff_confirm", FfLH::t("Confirm") . ">");
$confirmButton->addButtonListener(new ConfirmButtonListener());
$ffForm->addField($confirmButton);
class FormListener extends FfFormListener
{
function onNoClicks(&$ffForm)
{
// DEFAULT OPERATION:
// If necessary, convert the default values to multiple lines
if (sizeof($GLOBALS["FF_DEFAULTS"]) > 0) {
foreach ($GLOBALS["FF_DEFAULTS"] as $i=>$globalValue) {
$GLOBALS["FF_DEFAULTS"][$i] = str_replace("<br/>", "\n", $globalValue);
}
}
$ffForm->loadDbValues($GLOBALS["FF_DEFAULTS"]);
// Enter other default values here. Example:
//$ffForm->setValue("name", "John");
}
}
$ffForm->addFormListener(new FormListener());
define("FF_ENTER", 1);
define("FF_CONFIRM", 2);
define("FF_DONE", 3);
$GLOBALS["action"] = FF_ENTER;
$ffForm->setHiddenFields(array("ff_back", "ff_confirm"), true);
$ffForm->process();
// ---------- FORM ACTIONS - END ----------
/* END - SECTION 1 */
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?= FF_FORM_TITLE ?></title>
<? /* BEGIN - SECTION 2 */ ?>
<? require_once(FF_SRC . "/FfIncludes.php"); ?>
<? if ($GLOBALS["action"] == FF_DONE) { ?>
<meta http-equiv="Refresh" content="<?= FF_SLEEP ?>; url=<?= $GLOBALS["FORMfields/forms/generated/FF_DONE_URL"] ?>">
<? } ?>
<style type="text/css">
/* Sometimes it is useful to specify a label width */
/*label.notValid, label.isValid, label.disabled, label.display {
width: 150px;
}*/
</style>
<? /* END - SECTION 2 */ ?>
</head>
<body onload="setFocus();" class="FORMfields">
<? /* BEGIN - SECTION 3 */ ?>
<div class="ffForm">
<a name="ffStart"></a>
<?
// For debugging:
// print_r($_REQUEST);
// echo $ffForm->__toString();
?>
<form name="<?= $ffForm->getFormName() ?>" action="#ffStart" method="post" enctype="multipart/form-data">
<?= FfMenuHelper::getSectionTitleHeader(FF_FORM_TITLE) ?>
<? if ($GLOBALS["action"] == FF_DONE) { ?>
<br />
<div class="ffConfirmation">
<?= FfLH::t("Thank you for your submission.") ?>
</div>
<div class="ffRedirectNote">
<a href="<?= $GLOBALS["FORMfields/forms/generated/FF_DONE_URL"] ?>"><?= (FfLH::t("Please click here if your browser does not redirect in") . " " . FF_SLEEP . " " . FfLH::t("seconds") . ".") ?></a>
</div>
<br />
<? } else {
if ($GLOBALS["action"] == FF_CONFIRM) {
?>
<h3 class="FORMfields">
<?= FfLH::t("Please confirm that the following data is correct:") ?>
</h3>
<?
} else {
?>
<div style="text-align:right;margin-bottom:10px;">
<span class="required">*</span><span class="help" style="padding-left:0px;font-size:9px;"> - <?= FfLH::t("required") ?></span>
</div>
<?
}
echo $ffForm->getTableTag();
} ?>
<?= FfMenuHelper::getSectionTitleFooter() ?>
<div style="text-align:right;">
<a href="<?= FF_ROOT_URL ?>" target="_blank"><img class="ffTinyLogo" alt="FORMfields, The Premiere Web Framework." src="http://www.gwpoffice.com/FORMfields/images/blank.gif"/></a><a style="font: normal normal normal 9px verdana,sans-serif;" href="http://www.formfields.com" target="_blank">Form Generated by FORMgen</a>
</div>
<? if (FF_SHOW_W3C_VALIDATOR) { ?>
<div>
<a href="http://validator.w3.org/check?uri=referer"><img border="0" src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0!" height="31" width="88" /></a>
<a href="http://jigsaw.w3.org/css-validator/check/referer"><img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="Valid CSS!" /></a>
</div>
<? } ?>
</form>
</div>
<? /* END - SECTION 3 */ ?>
</body>
</html>
This post has been edited by warvilan: 8 Mar, 2008 - 06:40 AM