Link to home
Start Free TrialLog in
Avatar of Steve B
Steve BFlag for Australia

asked on

How to add multiple pages on a PHP form

I have generated an online customer satisfaction survey form for my customers to complete after they attended the show they booked from us.  The problem I am experiencing is that there are so many questions on the one page, that the customers often don't fill out the whole thing or don't fill it out at all.
I could of course, reduce the amount of questions, but then I won't get a good picture of how well our shows are.

Knowing this, I know that there are other websites that have surveys and what looks like multiple pages.  So they fill out the first 5 questions, click on NEXT, and fill out the next 5, etc, etc.

I just don't know how to set-up multiple pages with this generated PHP form, so that it goes to the next page, but all the data is still submitted into the same database.  I have attached the PHP script below.
<?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("FF_SLEEP", 4);
	define("FF_FORM_NAME", "event_customersurvey");
	define("FF_FORM_TITLE", htmlspecialchars("Event Customer Survey"));
	define("FF_STYLE_FILE", FF_ROOT_URL . "/styles/defaultWithStripes.css");
	define("FF_SHOW_W3C_VALIDATOR", false);
	define("FF_DISPLAY_CONFIRMATION", false); // 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", true);
	define("FF_FORM_EMAIL1_TO", "steve.b@madscience.com.au,steve@madscience.com.au");
	define("FF_FORM_EMAIL1_TO_FIELDS", "");
	define("FF_FORM_EMAIL1_FROM", "Customer_Satisfaction@madscience.com.au"); // 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", "Event Customer Survey Submission");
	define("FF_FORM_EMAIL1_MESSAGE_HEADER", "The following information has been generated by a customer who had booked an event with Mad Science.  The information contained herein is a true indication of the thoughts and choices of the customer.  The information has not been tampered with or altered since receipt of its transmission.<br/><br/>(From StartLogic - Servers ... Status Paid Active)");
	define("FF_FORM_EMAIL1_MESSAGE_FOOTER", "");
	define("FF_FORM_EMAIL1_USE_HTML", true);
	define("FF_FORM_EMAIL1_SEND_FORM_DATA", true);
 
	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", "Event Customer Survey 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", true);
	
	$GLOBALS["FF_CANCEL_URL"] = "/";
	$GLOBALS["FF_DONE_URL"] = "http://www.madscience.com/locations/nsw/ourservices.aspx?lang=1";
	
	$GLOBALS["FF_DEFAULTS"] = array(
 
	);
	
	// ---------- FORM PROPERTIES - END ----------
 
	// ---------- FORM STRUCTURE - START ----------
	
	$ffForm = new FfForm();
	$ffForm->addField(new HeaderField("MS_customer_satisfaction", "MAD SCIENCE CUSTOMER SATISFACTION SURVEY"));
	$ffForm->addField(new DescriptionField("IntroDesc", "<b><font size=\"2\" face=\"Arial\" color=\"#00000\">Mad Science is committed to providing the finest and most spectacular events, shows and science programs for children, businesses and schools. As a Mad Science customer, we value your comments regarding our events, as we have a strong commitment to providing shows that meets our audiences needs. Therefore your opinion is important to us. Please take a moment to answer the following questions. Thank You.</font></b>"));
	$ffForm->addField(new DescriptionField("RateDesc", "<font face=\"Arial\" size=\"2\" color=\"#FF0000\">On a scale of 1 to 10<br>where <i><u>1 means you strongly disagree</u></i> and <i><u>10 means you strong agree</u></i> please rate the following processes.</b></font>"));
	$ffForm->addField(new TextField("Name", "Customer / Company Name", FORM_FIELD_NOT_REQUIRED, 100, 5, null));
	$ffForm->formFields["Name"]->setFieldBelowLabel("on");
	$ffForm->addField(new TextField("EventDate", "Date of Event", FORM_FIELD_NOT_REQUIRED, 10, 10, null));
	$ffForm->formFields["EventDate"]->setHelp("Enter using this format dd/mm/yyyy");
	$ffForm->formFields["EventDate"]->setFieldBelowLabel("on");
	$ffForm->addField(new ListField("EventList", "Which Mad Science Event/Show did you have?", FORM_FIELD_REQUIRED, array("After School Program","Birthday Party","Corporate Event","Holiday Camp for families.","Holiday Camp for Camp Sites.","In-School Workshop","Live Stage Show","School Spectacular Show.","Special Event"), null, "[Select One]", 10));
	$ffForm->formFields["EventList"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("WellPlanned", "Was the event well planned and organized?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["WellPlanned"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("StartTime", "Did the event start on time?", FORM_FIELD_REQUIRED, array("Yes","No","Had to wait for attendees"), null, 3, null));
	$ffForm->formFields["StartTime"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("ShowLength", "Was the show long enough for everyone to participate?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["ShowLength"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Exp_Opportunity", "Was there enough time for to explore and experiment?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Exp_Opportunity"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Show_Safety", "Was the show performed in a safe way?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Show_Safety"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Chn_Attention", "Did the show engage the audience constantly?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Chn_Attention"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Content_Satisfaction", "Were you satisfied with the content (educational or entertainment)?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Content_Satisfaction"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("HandsOn_Exciting", "Were activites exciting for the audience?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["HandsOn_Exciting"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Show_Wow", "Did this show have the WOW factor?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, "on"));
	$ffForm->formFields["Show_Wow"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Take_Home_Good", "Were the Take-Home Experiments exciting and fun?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Take_Home_Good"]->setFieldBelowLabel("on");
	$ffForm->addField(new TextAreaField("MoreComments_Event", "Any further Comments about the Event", FORM_FIELD_NOT_REQUIRED, 500, 2, 10, 65));
	$ffForm->formFields["MoreComments_Event"]->setFieldBelowLabel("on");
	$ffForm->addField(new DescriptionField("Professor_Rating", "Professors Effectiveness"));
	$ffForm->addField(new TextField("NameOfProfessor", "Who was your Professor", FORM_FIELD_REQUIRED, 60, 4, null));
	$ffForm->formFields["NameOfProfessor"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Professors_Knowledge", "Was the professor Knowledgeable?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Professors_Knowledge"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Prof_Animated", "Was the professor animated and fun?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Prof_Animated"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Prof_PositiveAtti", "Was the professor full of positive energy?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Prof_PositiveAtti"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Prof_Joyous", "Was the professor courteous and funny?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Prof_Joyous"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Prof_Ques", "Did the professor answers all questions adequately?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Prof_Ques"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Prof_Entertaining", "Was the professor entertaining?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Prof_Entertaining"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Prof_Management", "Was the professor able to manage the audience in a positive way?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Prof_Management"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Prof_EnergyHarness", "Was the professor Energetic and maintained the spirit of the Show?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Prof_EnergyHarness"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Prof_Safety", "Was the professor safe and spoke about safety issues?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["Prof_Safety"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("Prof_Wow", "Did the professor have the WOW factor?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, "on"));
	$ffForm->formFields["Prof_Wow"]->setFieldBelowLabel("on");
	$ffForm->addField(new TextAreaField("Prof_MoreComments", "More Comments about the Professor", FORM_FIELD_NOT_REQUIRED, 500, 2, 10, 65));
	$ffForm->formFields["Prof_MoreComments"]->setFieldBelowLabel("on");
	$ffForm->addField(new DescriptionField("PromoSurvey", "Promotional Information"));
	$ffForm->addField(new RadioButtonField("ValueForMoney", "Was the show/event \"value for money\"?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, null));
	$ffForm->formFields["ValueForMoney"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("BookingGood", "Please rate our customer service.  From the booking to confirming, did we provide a high standard of customer service?", FORM_FIELD_REQUIRED, array("N/A","1","2","3","4","5","6","7","8","9","10"), null, 11, "on"));
	$ffForm->formFields["BookingGood"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("UseUsAgain", "Would you book another Mad Science Event or Show?", FORM_FIELD_REQUIRED, array("Yes","No","Maybe","Never"), null, 4, "on"));
	$ffForm->formFields["UseUsAgain"]->setHelp("If you answered, no, maybe or never (please tell us why).");
	$ffForm->formFields["UseUsAgain"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("RecommendUS", "Would you recommend Us?", FORM_FIELD_REQUIRED, array("Absolutely","Yes","No","Never"), null, 4, "on"));
	$ffForm->formFields["RecommendUS"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("UseAsReferee", "Could we use you or your comments as a customer testimonal?", FORM_FIELD_REQUIRED, array("Yes, absolutely","Yes, only comments.","Yes, only by phone","No"), null, 2, null));
	$ffForm->formFields["UseAsReferee"]->setFieldBelowLabel("on");
	$ffForm->addField(new TextAreaField("WhyRWeGreat", "What was it about Mad Science that you found to be better than other similar shows/programs?", FORM_FIELD_NOT_REQUIRED, 1000, 10, 10, 65));
	$ffForm->formFields["WhyRWeGreat"]->setFieldBelowLabel("on");
	$ffForm->addField(new RadioButtonField("CallBack", "Would you like us to call you back?", FORM_FIELD_NOT_REQUIRED, array("Yes","No"), null, 1, null));
	$ffForm->formFields["CallBack"]->setFieldBelowLabel("on");
	$ffForm->addField(new TextField("CallBackWork", "Work Telephone", FORM_FIELD_NOT_REQUIRED, 12, 8, null));
	$ffForm->formFields["CallBackWork"]->setFieldBelowLabel("on");
	$ffForm->addField(new TextField("CallBackHome", "Home Telephone", FORM_FIELD_NOT_REQUIRED, 12, 8, null));
	$ffForm->formFields["CallBackHome"]->setFieldBelowLabel("on");
	$ffForm->addField(new TextField("CallBackMobile", "Mobile", FORM_FIELD_NOT_REQUIRED, 12, 10, null));
	$ffForm->formFields["CallBackMobile"]->setFieldBelowLabel("on");
	$ffForm->addField(new SubmitField("ff_submit", "Submit"));
	$ffForm->addField(new SubmitField("ff_clear", "Clear"));
 
	// ---------- 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) {
					$ffForm->addField(new DateTimeField("ff_inserted_on", "Inserted On", FORM_FIELD_REQUIRED, null));
					$ffForm->formFields["ff_inserted_on"]->getCurrentDateTime();
					$ffForm->insertValuesIntoDb(FF_FORM_NAME);
				}
				
				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["FF_DONE_URL"] ?>">
<? } ?>
<style type="text/css">
.style1 {
	font-family: Arial;
	font-size: 12px;
	color: #000000;
	font-weight: bold;
}
.style2 {
	font-family: Arial;
	font-size: 12px;
	color: #000000;
}
.style3 {
	font-family: Arial;
	font-size: 12px;
	color: #FF0000;
}
</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["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>
					<?
				}
				
				?>
				<?= $ffForm->getIfError(); ?>
				<?= $ffForm->getHiddenFieldTag("ff_form_refresh") ?>
				<table border="4" cellpadding="2" cellspacing="2" bordercolor="#333333" class="ffTableSetFormFields">
					<tr class="ffTableSetFormFields">
						<td class="ffTableSetFormFields1" colspan="2"><div class="cell"><?= $ffForm->getFieldTag("MS_customer_satisfaction") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td class="ffTableSetFormFields2" colspan="2"><div class="cell"><?= $ffForm->getFieldTag("IntroDesc") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td class="ffTableSetFormFields1" colspan="2"><div class="cell"><?= $ffForm->getFieldTag("RateDesc") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
					  <td colspan="2" class="ffTableSetFormFields2 style1" >The following information is optional.</td>
				  </tr>
					<tr class="ffTableSetFormFields">
						<td width="93" valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("Name") ?></div></td>
						<td width="319" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("Name") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("EventDate") ?></div></td>
						<td class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("EventDate") ?></div></td>
					</tr>
					<tr bgcolor="#000000" class="ffTableSetFormFields">
					  <td colspan="2" class="ffTableSetFormFields2" >&nbsp;</td>
				  </tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("EventList") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("EventList") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
					  <td valign="top" bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("WellPlanned") ?></div></td>
						<td bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("WellPlanned") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("StartTime") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("StartTime") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
					  <td valign="top" bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("ShowLength") ?></div></td>
						<td bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("ShowLength") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("Exp_Opportunity") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("Exp_Opportunity") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
					  <td valign="top" bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("Show_Safety") ?></div></td>
						<td bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("Show_Safety") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("Chn_Attention") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("Chn_Attention") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
					  <td valign="top" bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("Content_Satisfaction") ?></div></td>
						<td bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("Content_Satisfaction") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("HandsOn_Exciting") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("HandsOn_Exciting") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
					  <td valign="top" bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("Show_Wow") ?></div></td>
						<td bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("Show_Wow") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("Take_Home_Good") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("Take_Home_Good") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
					  <td valign="top" bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("MoreComments_Event") ?></div></td>
						<td bgcolor="#999999" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("MoreComments_Event") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td class="ffTableSetFormFields2" colspan="2"><div class="cell"><em><strong><span class="style3"><br />
					    The following questions refer to Mad Professor.</span></strong></em></div></td>
					</tr>
					<tr bgcolor="#999999" class="ffTableSetFormFields">
					  <td valign="top" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("NameOfProfessor") ?></div></td>
					  <td class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("NameOfProfessor") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("Professors_Knowledge") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("Professors_Knowledge") ?></div></td>
					</tr>
					<tr bgcolor="#999999" class="ffTableSetFormFields">
					  <td valign="top" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("Prof_Animated") ?></div></td>
					  <td class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("Prof_Animated") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("Prof_PositiveAtti") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("Prof_PositiveAtti") ?></div></td>
					</tr>
					<tr bgcolor="#999999" class="ffTableSetFormFields">
					  <td valign="top" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("Prof_Joyous") ?></div></td>
					  <td class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("Prof_Joyous") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("Prof_Ques") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("Prof_Ques") ?></div></td>
					</tr>
					<tr bgcolor="#999999" class="ffTableSetFormFields">
					  <td valign="top" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("Prof_Entertaining") ?></div></td>
					  <td class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("Prof_Entertaining") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("Prof_Management") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("Prof_Management") ?></div></td>
					</tr>
					<tr bgcolor="#999999" class="ffTableSetFormFields">
					  <td valign="top" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("Prof_EnergyHarness") ?></div></td>
					  <td class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("Prof_EnergyHarness") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("Prof_Safety") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("Prof_Safety") ?></div></td>
					</tr>
					<tr bgcolor="#999999" class="ffTableSetFormFields">
					  <td valign="top" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("Prof_Wow") ?></div></td>
					  <td class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("Prof_Wow") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("Prof_MoreComments") ?></div></td>
						<td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("Prof_MoreComments") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td class="ffTableSetFormFields1" colspan="2"><div class="cell">
						  <p><em><strong><span class="style3"><br />
					      The following questions refer to Mad Science</span></strong></em></p>
						  </div></td>
					</tr>
					<tr bgcolor="#999999" class="ffTableSetFormFields">
					  <td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("ValueForMoney") ?></div></td>
					  <td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("ValueForMoney") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("BookingGood") ?></div></td>
						<td class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("BookingGood") ?></div></td>
					</tr>
					<tr bgcolor="#999999" class="ffTableSetFormFields">
					  <td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("UseUsAgain") ?></div></td>
					  <td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("UseUsAgain") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("RecommendUS") ?></div></td>
						<td class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("RecommendUS") ?></div></td>
					</tr>
					<tr bgcolor="#999999" class="ffTableSetFormFields">
					  <td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("UseAsReferee") ?></div></td>
					  <td class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getFieldTag("UseAsReferee") ?></div></td>
					</tr>
					<tr class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getLabelTag("WhyRWeGreat") ?></div></td>
						<td class="ffTableSetFormFields1" ><div class="cell"><?= $ffForm->getFieldTag("WhyRWeGreat") ?></div></td>
					</tr>
					<tr bgcolor="#999999" class="ffTableSetFormFields">
						<td valign="top" class="ffTableSetFormFields2" ><div class="cell"><?= $ffForm->getLabelTag("CallBack") ?>
						  <br />
						  <?= $ffForm->getFieldTag("CallBack") ?>
					  </div></td>
						<td class="ffTableSetFormFields2" ><div class="cell">
						  <?= $ffForm->getLabelTag("CallBackWork") ?><?= $ffForm->getFieldTag("CallBackWork") ?>
						  <br />
						  <?= $ffForm->getLabelTag("CallBackHome") ?><?= $ffForm->getFieldTag("CallBackHome") ?>
						  <br />
						  <?= $ffForm->getLabelTag("CallBackMobile") ?><?= $ffForm->getFieldTag("CallBackMobile") ?>
						  <br />
					  </div></td>
					</tr>
	  </table>
                <br />
<?= $ffForm->getFieldTag("ff_submit") ?> <?= $ffForm->getFieldTag("ff_clear") ?> 
				<?
 
				
			} ?>
			
		<?= FfMenuHelper::getSectionTitleFooter() ?>
		<div style="text-align:right;"></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>

Open in new window

Avatar of crush83
crush83
Flag of United States of America image

This is usually accomplished by passing a "page number" through $_GET, $_POST, or $_SESSION.

Personally, I rarely use $_POST for this.

Advantages of using $_GET is you can direct url's to a specific page for instance: http://www.mydomain.com/survey.php?page=3

Advantages of using $_SESSION is that your user can't manipulate the page number directly, cutting down on user error.

In your case I would suggest using $_SESSION, since you need to collect information throughout the steps. When a user submits the first page, then the $_SESSION variable should be updated with the values from the previous page, and you could increment a session variable such as $_SESSION['page']++;

As long as a user has an active session, their data and page number will be stored in the $_SESSION. Hope this helps.
Avatar of Steve B

ASKER

Hi crush83,

Thanks for the information.  The only problem is that because I am a beginner with this topic, what would I need to do so that the PHP form, knows which page to go to and how to store the data in the database.  Where would I put the $_SESSION command, and how will the form know which page to go to next?

Cheers.
$_SESSION is a global array. First you will need to do session_start(); at the beginning of each page that will be using the $_SESSION array.

After using session_start(); you can store information in $_SESSION, for example:

$_SESSION['pageid'] = 1;

Then when you are displaying your content, you could do:

if ($_SESSION['pageid'] == 1) {
 //Your code to display on page 1
} else if ($_SESSION['pageid'] == 2) {
 //Your code to display on page 2
} else if ($_SESSION['pageid'] == 3) {
 //Your code to display on page 3
} else {
 //Your code to display when the pageid is invalid
}


You could also use a switch:
switch ($_SESSION['pageid']) {
 case 1:
   include('page1.html');
   break;
 case 2:
   include('page2.html');
   break;
 case 3:
   include('page3.html');
   break;
 default:
  include('errorpage.html');
  break;
}


Obviously your code will need to be a little more advanced and intricate than that, but it should give a general idea.

You should also do some checking on $_SESSION['pageid'] before trying to use it to make sure it is set and not empty or set to an invalid value.
ASKER CERTIFIED SOLUTION
Avatar of AielloJ
AielloJ
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial