mercredi 8 novembre 2017

Php form math formula trouble

Hello I am working on this php form and i am having trouble setting up this math formula to give out the sum depending on what the user entered in the form. I feel like its something to do with not setting the variable correctly or something.

Instructions:

Now all price variables are set so you can calculate the total vacation price. Also, see formula below.

For 1 person for 1 night: Add their base vacation price to the type they chose.

For 1 person for multiple nights: Add their vacation price times the number of nights they plan to stay.

((50 + 60) * 4 * 2) + (300 * 2) = $1440

((Base + Type) * numDays * numPeople) + (airfare * numPeople) = TotalTripCost

My Code related to this:

$fName = $_GET["fName"];
$lName = $_GET["lName"];
$travDest = $_GET["travDest"];
$type = $_GET["type"];
$numPpl = $_GET["numPpl"];
$numDays = $_GET["numDays"];
$airfare = $_GET["airfare"];
    $TotalTripCost = "TotalTripCost";

if ($_GET["numPpl"] == "one" and $_GET["numDays"] == 1) {
    ((50 + $_GET["type"]) * $_GET["numDays"] * $_GET["numPpl"]) + ($_GET["airfare"] * $_GET["numPpl"]) == $TotalTripCost;
    echo "<br>Your total vacation amount is $TotalTripCost.";
}  //One Person, One Night

else if ($_GET["numPpl"] == "one" and $_GET["numDays"] == >1) {
    ((50 + $_GET["type"]) * $_GET["numDays"] * $_GET["numPpl"]) + ($_GET["airfare"] * $_GET["numPpl"]) == $TotalTripCost;
    echo "<br>Your total vacation amount is $TotalTripCost.";
}  //One Person, Multiple Nights

Aucun commentaire:

Enregistrer un commentaire