There were form entry errors
    StartErrors; foreach ($ErrorArray as $Error) { echo "
  • $Error\n"; } # End of foreach ($ErrorArray as $Error) print<<

    Please fix errors on the form below and resubmit

StopErrors; ShowForm(); } # End of function DisplayErrors ############################################# # Function MakeCheckBoxes ##################################################### function MakeCheckBoxes($Name,$PromptsAndValues,$Selected) { $ArrayCount = count($PromptsAndValues); for($Index=0;$Index<$ArrayCount;$Index++) { $String .=<<" : ">"; $String .= "\n"; } # End of for ($Index=0;$Index $Title - $Heading

$Title - $Heading

HTMLtop; } # End of function MakeHTMLtop ############################################### # Function MakeRadioButtons() ################################################# function MakeRadioButtons($Name,$Current, $Values=array(1,0),$Prompt=array("Yes","No")) { /* This function returns a string containing a formatted set of radio buttons. There are two required parameters and two optional parameters. The first positional parameter the value used for the NAME= parameter. The second positional parameter is the current value of the bottom variable. Simply pass the variable containing the current value. The third parameter (optional) is an array of possible values. The default is (1,0). The last parameter (optional) is an array of prompts. The default is ("Yes","No"). The relative position in the array should correspond with the values array. If the function is called with: MakeRadioButtons("Gender","Male",array("M","F"),array("Male:","Female:")); the following would be returned: Male: Female: If the call was: MakeRadioButtons("Married","1") the returned string would be: Yes: No: */ for($Index=0;$Index" : ">"; $String .= "\n"; } # End of for ($Index=0;$Index DropMenu; if ($Selected) { $DropMenu = preg_replace("|\"$Selected\">*|","\"$Selected\" SELECTED>",$DropMenu); } # if ($Selected) return $DropMenu; } # End of function MakeStateDropMenu ######################################### # Function ShowForm() ######################################################### function ShowForm() { global $PHP_SELF; # The path and name of this file global $FirstName, $LastName, $Gender, $City, $State, $Comments, $OperatingSystem, $FavoriteLanguage; $Comments = stripslashes($Comments); $Selected = ($State) ? $State : "NJ"; $StateDropMenu = MakeStateDropMenu("State",$Selected); $GenderButtons = MakeRadioButtons("Gender","$Gender",array("Male","Female"),array("Male","Female")); $FavoriteLanguageButtons = MakeRadioButtons("FavoriteLanguage","$FavoriteLanguage", array("PHP","Perl","C++","Other"), array("PHP","Perl","C++","Other")); $OperatingSystemBoxes = MakeCheckBoxes( "OperatingSystem",array("Unix","Linux","Windows 2000","Windows 9x","Other"), $OperatingSystem); # Last parameter is an array # array("Value1","Value2") if last parameter is an array of constants # $OneBox = MakeCheckBoxes("OneBox",array("Unix"),array("Unix")); $HTML=<<
First Name: Last Name:
City: State: $StateDropMenu
Your Gender? $GenderButtons
Your favorite Web programming language? $FavoriteLanguageButtons
What Operating Systems have you used? Check all that apply.
$OperatingSystemBoxes
$OneBox
What do you think are PHP strengths and weaknesses?
HTML; echo $HTML; exit; } # End of function ShowForm ################################################## # Function ShowResults () ##################################################### function ShowResults () { global $HTTP_USER_AGENT, $FirstName, $LastName, $Gender, $City, $State, $Comments, $OperatingSystem, $FavoriteLanguage; $Comments = nl2br($Comments); $Comments = stripslashes($Comments); $OSchoices = join(", ",$OperatingSystem); $FormResults=<<
Your Name: $FirstName $LastName
Your Address: $City, $State
Your Gender: $Gender
Favorite Programming Language: $FavoriteLanguage
Operating System Used:
$OSchoices
Your Comments About PHP
$Comments
are appreciated.
Pleased to see you are using:
$HTTP_USER_AGENT
FormResults; print $FormResults; } # End of function ShowResults ############################################### ?>