I am trying to make a form for an upcoming technology conference…
The PHP code should make sure the user has entered (or selected) items for each area. If the user does not select something an error message must appear that asks them to go back to the form and complete all information.I want the program to use functions to calculate the cost of the conference, and to calculate the cost of meals. The functions should return the calculated costs back to the main program.
The program will also generate a random number (1 to 1000) as the user’s conference id.
The program will print out a message similar to the following:
John Smith, you have registered for three days, with a meal plan, your total cost will be $325. Please make sure to bring cash, or your credit card to pay for the conference on the first day. Your confirmation number is 999. See you soon!
[code]
body { color:black; font-size:20px; } h1 { color:orange; text-align:center; font-size:30px; } p { font-family:"Times New Roman"; font-size:20px; } MAJOR PROJECT 1 PHPNerd Roundup
Please type your first name:Please type your Last name:
Please type your city:
<input type = "text"
name = "city"
value = "" /> <br />
Please type your State:
<input type = "text"
name = "state"
value = "" /> <br />
Please type your Zipcode:
<input type = "text"
name = "zipCode"
value = "" /> <br />
Anything else you want to add?
<fieldset>
DO YOU WANT THE MEAL PLAN?
YES
NO
NERD TRACK
PROGRAMMING TRACK NETWORKING TRACK SECURITY TRACK WEB TRACK place order [/code] [php] body {background-color:#FF00FF;
}
h1
{
color:orange;
text-align:center;
}
p
{
font-family:“Times New Roman”;
font-size:20px;
}
h1 {text-align:center;
}
Personal Information
<?php // define the variables $confId = rand(1,1000); $fName = $_POST["fName"]; $lName = $_POST ["lName"]; $city = $_POST ["city"]; $state = $_POST ["state"]; $zipCode = $_POST["zipCode"]; $other = $_POST ["other"]; $chkOne = $_POST["chkOne"]; $chkTwo = $_POST["chkTwo"]; $chkThree = $_POST["chkThree"]; $mealPlan = $_POST[""]; $confTotal = 0; $no_errors = TRUE; $total = 0; checkInput(); calcPrice(); printConf(); //checkInput function checkInput() { if (filter_has_var(INPUT_POST, "chkOne")){ print "ONE DAY CONFERENCE
\n"; $total += filter_input(INPUT_POST, "chkOne"); } if (filter_has_var(INPUT_POST, "chkTwo")){ print "TWO DAY CONFERENCE
\n"; $total += filter_input(INPUT_POST, "chkTwo"); } if (filter_has_var(INPUT_POST, "chkThree")){ print "THREE DAY CONFERENCE
\n"; $total += filter_input(INPUT_POST, "chkThree"); } //end $total if (filter_has_var(INPUT_POST, "mealPlan")){ } if (filter_has_var(INPUT_POST, "noFood")){ } // do they want the meal plan $track = filter_input(INPUT_POST, "track"); // what conference track are they on if(empty($fName)) { $no_errors = FALSE; echo '***FIRST NAME FIELD REQUIRED*****' ; } //get users first name if(empty($lName)) { $no_errors = FALSE; echo '****LAST NAME FIELD REQUIRED*****
'; } // get users last name if(empty($city)) { $no_errors = FALSE; echo '****CITY FIELD REQUIRED*****
'; } //get user city if(empty($state)) { $no_errors = FALSE; echo '***STATE NAME FIELD REQUIRED*****
'; } //get user state if(empty($zipCode)) { $no_errors = FALSE; echo '****ZIPCODE FIELD REQUIRED*****
'; } //get user zip code if(empty($other)) { $no_errors = FALSE; echo '****TEXT FIELD REQUIRED*****
'; } //get user additional comments if ($no_errors == FALSE) { echo "
Go back to form"; } }//end function checkInput //beging function calculateCost function calcPrice(){ global $total; $confTotal =filter_input(INPUT_POST,"confTotal"); $total = filter_input (INPUT_POST, "total"); $mealPlan = filter_input (INPUT_POST, "mealPlan"); IF (! filter_has_var (INPUT_POST, "mealPlan" )){ $total =="100" ; $confTotal = $total+= 50; } else if ($total=="175"){ $confTotal = $total +=75; } else if ($total =="225"){$confTotal = $total +=100; $no_errors == TRUE; }} //end function cacluclateCost //begin function printConf function printConf(){ if ($no_errors == TRUE) { print "
$fName $lName,
you have registered for Nerd Roundup 2013
your planned track is $track
You choose -confDay
with -mPlan
The total cost is: \$$total
I hear the climate around $zipCode is great this time of year.
Please make sure to bring cash, or your credit card to pay for the conference on the first day
Your additional comments are as follows:
$other
Your Nerd Roundup confirmation number is $confId .
\n"; } } //end function printConf ?> [/php]