George's Business - Ordering\n"); /* Echo the link for loading the stylesheet. The line needs to appear in quotes, so any quotes in the line need to be escaped. For clarity of reading the source that appears at the browser (if you need to debug) it is also nice to add a newline to the end. */ echo("\n"); /* Close off the headers and add the body tag */ echo("\n\n"); /* Add the default content from the other pages to ensure consistency. */ echo("

George's Business - Ordering

\n"); echo("
\n"); echo("
\n"); echo("

\"We do it right or we do it again.\"

\n"); echo("
\n"); echo("
\n"); echo("
 Home | Products | Pricing | Ordering | Contact Us | About the President
\n"); echo("
\n"); echo("
\n"); echo("
\n"); /* Now retrieve the information sent in the form and nicely echo it to the screen along with a calculation of the total cost based on whatever was selected for purchase. */ /* First get the Name, this will be in the $_GET dictionary under 'name' (the name property of the input tag). We can use the function isset to see if the data was supplied (ie the Name field was filled in). If it is not set, we will want to re-echo the old page with a note to fill in the missing field, for now, we can just set a flag to let us know to re-echo */ $recho = 0; /* This flag lets us know if we have to re-echo the page */ if (isset($_GET["name"]) && strcmp($_GET["name"], "") != 0) { $name = $_GET["name"]; } else { /* No name, set $name to 're-echo' and set $recho flag to 1 */ $name = 're-echo'; $recho = 1; } /* Now get the address...same thing here, if it is not set, set the echo flag and set address1 to re-echo. Only caveat here is that if address2 is not set, you can set it to an empty string. */ if (isset($_GET["address1"]) && strcmp($_GET["address1"], "") != 0) { $address1 = $_GET["address1"]; /* Grab $address2, you do not need to check if it is an empty string because it might be anyway, and that is fine. */ $address2 = $_GET["address2"]; } else { /* The first address field is missing so set $address to 're-echo' and set the echo flag. */ $address1 = 're-echo'; $address2 = ""; $recho = 1; } /* Now get the City, same sort of approach. */ if (isset($_GET["city"]) && strcmp($_GET["city"], "") != 0) { $city = $_GET["city"]; } else { /* No city */ $city = 're-echo'; $recho = 1; } /* Country */ if (isset($_GET["country"]) && strcmp($_GET["country"], "") != 0) { $country = $_GET["country"]; } else { /* No country */ $country = 're-echo'; $recho = 1; } /* Postal code */ if (isset($_GET["pcode"]) && strcmp($_GET["pcode"], "") != 0) { $pcode = $_GET["pcode"]; } else { /* No postal code */ $pcode = 're-echo'; $recho = 1; } /* Product */ if (isset($_GET["product"]) && strcmp($_GET["product"], "") != 0) { $product = $_GET["product"]; } else { /* No product */ $product = 're-echo'; $recho = 1; } /* Quantity */ if (isset($_GET["quantity"]) && strcmp($_GET["quantity"], "") != 0) { $quantity = $_GET["quantity"]; } else { $quantity = 're-echo'; $recho = 1; } /* Check if we need to re-echo the page. If we do, then re-echo with a message saying to fill in missing fields, but if not, then echo then calculate the cost and echo the input to the screen. */ if ($recho == 1) { /* We need to re-echo the page. We will need to add the table in and the form. Any field which is set to 're-echo' should have an asterix by the form and at the top above the table, we should put a message "* Fill in missing field(s)". Any fields which are already input should have their value set to whatever was provided. */ echo("

* Fill in missing field(s)


\n"); echo("
\n"); echo("\n"); echo(" \n"); echo(" \n"); if (strcmp($name, "re-echo") == 0) { echo(" \n"); } else { echo(" \n"); } echo(" \n"); echo(" \n"); echo(" \n"); if (strcmp($address1, "re-echo") == 0) { echo(" \n"); } else { echo(" \n"); } echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); if (strcmp($city, "re-echo") == 0) { echo(" \n"); } else { echo(" \n"); } echo(" \n"); echo(" \n"); echo(" \n"); if (strcmp($country, "re-echo") == 0) { echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); if (strcmp($pcode, "re-echo") == 0) { echo(" \n"); } else { echo(" \n"); } echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); echo(" \n"); if (strcmp($product, "re-echo") == 0) { echo(" \n"); echo(" \n"); echo(" \n"); echo(" "); if (strcmp($quantity, "re-echo") == 0) { echo(" \n"); } else { echo(" \n"); } echo(" \n"); echo("
Name: *
Address: *
City: *
Country: *\n"); } else { echo(" \n"); } echo(" \n"); echo("
Postal Code: *
 
 
Item: *\n"); } else { echo(" \n"); } echo(" \n"); echo("
Quantity: *
\n"); echo("
\n"); echo("
\n"); } else { echo("

Shipping Address

\n"); echo("$name
\n$address1
\n"); if (strcmp($address2, "") != 0) { echo("$address2
\n"); } echo("$city, $country
\n"); echo("$pcode
\n"); echo("

Order

\n"); echo("$quantity x "); if (strcmp($product, "hydrospanner") == 0) { echo("Hydrospanner"); $cost = $quantity * 1922.95; } if (strcmp($product, "fluxcapacitor") == 0) { echo("Flux Capacitor"); $cost = $quantity * 58.75; } if (strcmp($product, "temporalregurgitator") == 0) { echo("Temporal Regurgitator"); $cost = $quantity * 5286322.0; } echo("    \$$cost\n"); echo("

\n"); echo("Change your order\n"); } /* Close up the body. */ echo("\n\n"); ?>