473,324 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Making an order form for a pizza company

I finished an order form for a pizza company. It works but they want me to implement some math into it. I am unsure how to go about this, and am hoping I don't have to rewrite the entire form and php.

Form
Expand|Select|Wrap|Line Numbers
  1. <form name="Pizza" method="post" action="formsent.php">
  2.                     <div class="row">
  3.                         <p>
  4.                             <label>Your Name</label>
  5.                             <input type="text" name="name" class="text_field" />
  6.                         </p>
  7.                         <p>
  8.                             <label>Your Email</label>
  9.                             <input type="text" name="email" class="text_field" />
  10.                         </p>
  11.                     </div>
  12.                     <div class="row">
  13.                         <p>
  14.                             <label>Your Phone Number</label>
  15.                             <input type="text" name="phone" class="text_field" />
  16.                         </p>
  17.                                                 <p>
  18.                             <label>Your Address</label>
  19.                             <input type="text" name="address" class="text_field" />
  20.                         </p>
  21.                         <!-- <p>
  22.                             <label>Subject</label>
  23.                             <select class="text_field" name="subject">
  24.                                 <option>Select a subject...</option>
  25.                                 <option>Option 2</option>
  26.                             </select> -->
  27.                         </p>
  28.                     </div>
  29.                     <label>Size of Pizza  Type of Crust  Pre-Packaged Special or Gourmet Pizza</label>
  30. <SELECT NAME="size">
  31. <OPTION>Medium
  32. <OPTION>Large
  33. <OPTION>Extra Large
  34. </SELECT>
  35.  
  36. <SELECT NAME="crust">
  37. <OPTION>Regular Crust
  38. <OPTION>Thick Crust
  39. </SELECT>
  40.  
  41. <SELECT NAME="type">
  42. <OPTION>Other Items; No Pizza
  43. <OPTION>Create Your Own
  44. <OPTION>Combination
  45. <OPTION>Margarita
  46. <OPTION>Canadian
  47. <OPTION>Hawaiian
  48. <OPTION>Vegetarian
  49. <OPTION>Mexican
  50. <OPTION>Meat Lovers
  51. <OPTION>Greek
  52. <OPTION>Chicken Fajita
  53. <OPTION>Vege Extreme
  54. <OPTION>Michael's Original
  55. <OPTION>Mediterranean
  56. </SELECT>
  57. <div align="left">
  58. <b>Create your Own Toppings</b><br>
  59. <INPUT TYPE="checkbox" NAME="topping1" VALUE="Pepperoni">             Pepperoni <br>   
  60. <INPUT TYPE="checkbox" NAME="topping2" VALUE="Salami">               Salami <br>        
  61. <INPUT TYPE="checkbox" NAME="topping3" VALUE="Canadian Style Bacon">    Canadian Style Bacon <br>
  62. <INPUT TYPE="checkbox" NAME="topping4" VALUE="Fresh Mushrooms">         Fresh Mushrooms<br>
  63. <INPUT TYPE="checkbox" NAME="topping5" VALUE="Black Olives">            Black Olives <br>  
  64. <INPUT TYPE="checkbox" NAME="topping6" VALUE="Green Peppers">         Green Peppers<br> 
  65. <INPUT TYPE="checkbox" NAME="topping7" VALUE="Ground Beef">             Ground Beef <br>   
  66. <INPUT TYPE="checkbox" NAME="topping8" VALUE="Italian Sausage">         Italian Sausage <br> 
  67. <INPUT TYPE="checkbox" NAME="topping9" VALUE="Fresh Tomatoes">           Fresh Tomatoes <br> 
  68. <INPUT TYPE="checkbox" NAME="topping10" VALUE="Onions">                     Onions <br>
  69. <INPUT TYPE="checkbox" NAME="topping11" VALUE="Pineapple">               Pineapple <br> 
  70. <INPUT TYPE="checkbox" NAME="topping12" VALUE="Jalapeno Peppers">          Jalapeno Peppers<br>
  71. <INPUT TYPE="checkbox" NAME="topping13" VALUE="Anchovies">               Anchovies <br>    
  72. <INPUT TYPE="checkbox" NAME="topping14" VALUE="Extra Cheese">         Extra Cheese<br> 
  73. </div>
  74. <Label> Appetizers</Label>
  75. <SELECT NAME="apps">
  76. <OPTION>None
  77. <OPTION>Wedges
  78. <OPTION>Seasoned Fries
  79. <OPTION>Poutine (Large)
  80. <OPTION>Poutine (Small)
  81. <OPTION>Onion Rings
  82. <OPTION>Mozzerella Sticks
  83. <OPTION>Garlic Bread
  84. <OPTION>Garlic Bread with Cheese
  85. <OPTION>Macaroni Salad
  86. <OPTION>Soup
  87. </SELECT>
  88. <br />
  89. <label>Salads</label>
  90. <SELECT NAME="salad">
  91. <OPTION>None
  92. <OPTION>Garden Salad
  93. <OPTION>Greek Salad
  94. <OPTION>Mediterranean Greek Salad
  95. <OPTION>Caesar Salad
  96. <OPTION>Chef Salad
  97. </SELECT>
  98. <br /><label>Baked Pockets</label>
  99. <SELECT NAME="pocket">
  100. <OPTION>None
  101. <OPTION>Spinach &amp; Feta Pocket
  102. <OPTION>Mediterranean Pocket
  103. <OPTION>Greek Pocket
  104. <OPTION>Steak Pocket
  105. <OPTION>Club Pocket
  106. <OPTION>Veggie Pocket
  107. <OPTION>Deli Pocket
  108. <OPTION>Build Your Own Pocket ($1/extra topping)
  109. </SELECT>
  110. <br /><label>Fried Chicken</label>
  111. <SELECT NAME="chicken">
  112. <OPTION>None
  113. <OPTION>2 piece Dinner
  114. <OPTION>3 piece Dinner
  115. <OPTION>4 piece Dinner
  116. <OPTION>3 piece Chicken
  117. <OPTION>6 piece Chicken
  118. <OPTION>9 piece Chicken
  119. <OPTION>12 piece Chicken
  120. </SELECT>
  121. <br /><label>Chicken Wings</label>
  122. <SELECT NAME="wings">
  123. <OPTION>None
  124. <OPTION>10 wings
  125. <OPTION>20 wings
  126. <OPTION>30 wings
  127. </SELECT>
  128. <SELECT NAME="sauce">
  129. <OPTION>No Sauce
  130. <OPTION>Hot Sauce
  131. <OPTION>Mild Sauce
  132. <OPTION>Honey Garlic
  133. <OPTION>BBQ Sauce
  134. </SELECT>
  135. <br /><label>Burgers</label>
  136. <SELECT NAME="burgers">
  137. <OPTION>No Burger
  138. <OPTION>Sirloin Burger
  139. <OPTION>Pizza Burger
  140. <OPTION>Bacon Cheese Burger
  141. <OPTION>Chicken Burger
  142. <OPTION>The Ringer
  143. <OPTION>Swiss Burger
  144. <OPTION>Firehouse Burger
  145. <OPTION>Sliders
  146. </SELECT>
  147. <br /><Label>Toasted Subs</Label>
  148. <SELECT NAME="subs">
  149. <OPTION>No Sub
  150. <OPTION>Deluxe
  151. <OPTION>Chicken Club
  152. <OPTION>Steak Sub
  153. <OPTION>BBQ Chicken
  154. <OPTION>Pizza Sub
  155. <OPTION>Gyro Sub
  156. </SELECT>
  157. <br /><Label>Desserts</Label>
  158. <SELECT NAME="dessert">
  159. <OPTION>None
  160. <OPTION>Brownies
  161. <OPTION>Cheesecake
  162. <OPTION>Fried Sugar Doughballs
  163. </SELECT>
  164.                     <p>
  165.                         <label>Additional Input</label>
  166.                         <textarea class="text_field" rows="10" cols="10" name="info"></textarea>
  167.                     </p>
  168.                     <input type="submit" class="button" value="Send Message" />
  169.                 </form>
PHP
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. if(isset($_POST['email'])) {
  3.  
  4.     // EDIT THE 2 LINES BELOW AS REQUIRED
  5.     $email_to = "order@slicesandsquares.com";
  6.     $email_subject = "Pizza Order";
  7.  
  8.         function died($error) {
  9.         // your error code can go here
  10.         echo "We are very sorry, but there were error(s) found with the form you submitted. ";
  11.         echo "These errors appear below.<br /><br />";
  12.         echo $error."<br /><br />";
  13.         echo "Please go back and fix these errors.<br /><br />";
  14.         die();
  15.     }
  16.     // validation expected data exists
  17.     if(!isset($_POST['name']) ||
  18.         !isset($_POST['address']) ||
  19.         !isset($_POST['size']) ||
  20.         !isset($_POST['crust']) ||
  21.         !isset($_POST['type']) ||
  22.         !isset($_POST['phone'])){
  23.         died('We are sorry, but there appears to be a problem with the form you submitted.');       
  24.     }
  25.  
  26.     $first_name = $_POST['name']; // required
  27.     $email_from = $_POST['address']; // required
  28.     $comments = $_POST['phone']; // required
  29.     $size = $_POST['size']; // required
  30.     $crust = $_POST['crust']; // required
  31.     $type = $_POST['type']; // required
  32.     $t1 = $_POST['topping1']; // required
  33.     $t2 = $_POST['topping2']; // required
  34.     $t3 = $_POST['topping3']; // required
  35.     $t4 = $_POST['topping4']; // required
  36.     $t5 = $_POST['topping5']; // required
  37.     $t6 = $_POST['topping6']; // required
  38.     $t7 = $_POST['topping7']; // required
  39.     $t8 = $_POST['topping8']; // required
  40.     $t9 = $_POST['topping9']; // required
  41.     $t10 = $_POST['topping10']; // required
  42.     $t11 = $_POST['topping11']; // required
  43.     $t12 = $_POST['topping12']; // required
  44.     $t13 = $_POST['topping13']; // required
  45.     $t14 = $_POST['topping14']; // required
  46.     $apps = $_POST['apps']; // required
  47.     $salad = $_POST['salad']; // required
  48.     $pocket = $_POST['pocket']; // required
  49.     $chicken = $_POST['chicken']; // required
  50.     $wings = $_POST['wings']; // required
  51.     $sauce = $_POST['sauce']; // required
  52.     $burgers = $_POST['burgers']; // required
  53.     $subs = $_POST['subs']; // required
  54.     $dessert = $_POST['dessert']; // required
  55.     $info = $_POST['info']; // required
  56.  
  57.     // $error_message = "";
  58.     // $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
  59.   // if(!preg_match($email_exp,$email_from)) {
  60.    //  $error_message .= 'The Email Address you entered does not appear to be valid.<br />';
  61.   // }
  62.     $string_exp = "/^[A-Za-z .'-]+$/";
  63.   if(!preg_match($string_exp,$first_name)) {
  64.     $error_message .= 'The First Name you entered does not appear to be valid.<br />';
  65.   }
  66.   if(strlen($comments) < 2) {
  67.     $error_message .= 'The Comments you entered do not appear to be valid.<br />';
  68.   }
  69.   if(strlen($error_message) > 0) {
  70.     died($error_message);
  71.   }
  72.     $email_message = "Form details below.\n\n";
  73.  
  74.     function clean_string($string) {
  75.       $bad = array("content-type","bcc:","to:","cc:","href");
  76.       return str_replace($bad,"",$string);
  77.     }
  78.  
  79.     $email_message .= "name: ".clean_string($first_name)."\n";
  80.     $email_message .= "address: ".clean_string($email_from)."\n";
  81.     $email_message .= "phone: ".clean_string($comments)."\n";
  82.     $email_message .= "size: ".clean_string($size)."\n";
  83.     $email_message .= "crust: ".clean_string($crust)."\n";
  84.     $email_message .= "type: ".clean_string($type)."\n";
  85.     $email_message .= "topping1: ".clean_string($t1)."\n";
  86.     $email_message .= "topping2: ".clean_string($t2)."\n";
  87.     $email_message .= "topping3: ".clean_string($t3)."\n";
  88.     $email_message .= "topping4: ".clean_string($t4)."\n";
  89.     $email_message .= "topping5: ".clean_string($t5)."\n";
  90.     $email_message .= "topping6: ".clean_string($t6)."\n";
  91.     $email_message .= "topping7: ".clean_string($t7)."\n";
  92.     $email_message .= "topping8: ".clean_string($t8)."\n";
  93.     $email_message .= "topping9: ".clean_string($t9)."\n";
  94.     $email_message .= "topping10: ".clean_string($t10)."\n";
  95.     $email_message .= "topping11: ".clean_string($t11)."\n";
  96.     $email_message .= "topping12: ".clean_string($t12)."\n";
  97.     $email_message .= "topping13: ".clean_string($t13)."\n";
  98.     $email_message .= "topping14: ".clean_string($t14)."\n";
  99.     $email_message .= "apps: ".clean_string($apps)."\n";
  100.     $email_message .= "salad: ".clean_string($salad)."\n";
  101.     $email_message .= "pocket: ".clean_string($pocket)."\n";
  102.     $email_message .= "chicken: ".clean_string($chicken)."\n";
  103.     $email_message .= "wings: ".clean_string($wings)."\n";
  104.     $email_message .= "sauce: ".clean_string($sauce)."\n";
  105.     $email_message .= "burgers: ".clean_string($burgers)."\n";
  106.     $email_message .= "subs: ".clean_string($subs)."\n";
  107.     $email_message .= "dessert: ".clean_string($dessert)."\n";
  108.     $email_message .= "info: ".clean_string($info)."\n";
  109.  
  110.  
  111. // create email headers
  112. $headers = 'From: '.$email_from."\r\n".
  113. 'Reply-To: '.$email_from."\r\n" .
  114. 'X-Mailer: PHP/' . phpversion();
  115. @mail($email_to, $email_subject, $email_message, $headers);  
  116. ?>
  117.  
  118. <!-- include your own success html here -->
  119.  
  120. Thank you for contacting us. We will be in touch with you very soon.
  121.  
  122. <?php
  123. }
  124. ?>
So basically I need to add a value to each of the items. I thought about just switching the drop boxes to check boxes and using php to do the math, but am uncertain how I would make it so only the checked boxes are calculated. If there is an easier way that would be greatly appreciated.
I will also have to add an if statement.
They want the total + tax and a delivery fee ($3.50) if the total is under $30 before taxes.

I am recently out of school and this is on the my first projects and its gotten a little confusing. Any help would be appreciated.

Thank you in advance.
Dec 20 '11 #1
3 5464
zorgi
431 Expert 256MB
"drop boxes to check boxes" ... why? Options within drop boxes can have values?
Dec 20 '11 #2
Okay thanks. The only issue I have left is setting the toppings and specialty pizzas. They each would have 3 different values. (Small, Medium and Large) How would I go about doing that. I've been brainstorming and wondering if maybe I could have the options swap depending on which option I select (Small, Medium, Large) Perhaps lines of if, if else statements in the php. Or somehow using classes to select between the three options. Other than that, I have it set up. Thanks again.
Dec 22 '11 #3
Let me know your issue excatly.
where you need to calculation
1)when user is ordering for pizza ?
or
2)when sending the mail ?
Dec 26 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Daniel Ruscoe | last post by:
Hi chaps, I'm relatively new to the language, but I want to create a simple order form using PHP and cookies. Please let me know if there's a better way in this situation, database isn't...
4
by: CK | last post by:
Hi all, I know this question is stupid. But i need some advice for this. I am trying to develop a website, which will allow the user send to order form to the admin email. I am planning to use the...
1
by: Kelly B. | last post by:
Hello I've created a customer database for the company I work for. Now I've started on building a work order, which will be related to It. Basically, I need to build a form to accept shirt size...
1
by: Joey Mok | last post by:
Hi, How to create a Sales Order form with ASP.NET 2.0? I want to save the sales order header and its items at the same time. Can I make this web form with ASP.NET 2.0 new Data Controls? ...
4
by: papawilley | last post by:
How do I right JavaScript, quantity calculations for an existing online order form. I am trying to make an order form that will have a open price, added to a set price selected from a drop down box,...
5
by: hlebforprimeminister | last post by:
Hi I am creating a purchase order form in access. I have to create a single form to enter the information into 3 different tables (let's call X, Y, Z). Each of these tables has an autonumber...
8
by: mbatestblrock | last post by:
Hey all you PHP gods and goddesses, I was hoping for a pointer for a tutorial, perhaps some teachings on creating an order form. I am not asking for a complete explanation by anyone here but was...
1
by: Deccypher | last post by:
Hi I am trying to give my customers an option to save favorite products for easy storage and reorderig. it works great and on the single item add to cart i have no problem, how ever i would also...
6
by: Palehorse | last post by:
I'd like to apologize upfront for me saying "I'm not a programer", I'm sure you all hear this a hundred times a day. Unfortunately, in this case, it's true. I've been working on trying to figure out...
1
by: Bongani Mgibi | last post by:
What code must I use if I want to create an order form on my website where patrons can order and/or request multiple products and/or services from the price list with different pricing, the order...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.