Note that there are some explanatory texts on larger screens.

plurals
  1. POSending PHP Form Data
    primarykey
    data
    text
    <p>I'm trying to create an online order form using PHP.</p> <p>I've already got it working using PHP Checkboxes for each item.</p> <p>But now I want to remove the Checkboxes - replacing them with a Quantity box and a Message box for each item.</p> <p>Here is how I currently have my order form setup with checkboxes (I removed the checkbox from the 1st item "Mexican Tortas," and added the Quantity &amp; Message boxes as an example).</p> <p>What is the best way to go about this, so that only the items that have data entered into the Quantity box (and Message box) will be sent to my email?</p> <p><strong>HTML:</strong></p> <pre><code>&lt;div class ="item_left"&gt; &lt;img src="images/mexicantortas.jpg" border="2" width="200px" height="150px"&gt;&lt;br&gt; Mexican Torta - $8.50&lt;input name="item" type="hidden" value="Mexican Torta"/&gt;&lt;br&gt; How Many? &lt;input name="quantity" type="text" style="width: 20px; height: 12px;"/&gt;&lt;br&gt; &lt;input name="message" type="text" value="Enter special order instructions here..." style="max-width: 200px; height: 30px;"/&gt; &lt;/div&gt;&lt;!-- ITEM_LEFT --&gt; &lt;div class ="item_center"&gt; &lt;img src="images/fishsandwich.jpg" border="2" width="200px" height="150px"&gt;&lt;br/&gt; Fish Sandwich - $8.50&lt;input name="item" type="hidden" value="Fish Sandwich"/&gt;&lt;br&gt; &lt;input type="checkbox" name="check[]" value="Fish Sandwich"&gt;&lt;br/&gt; &lt;/div&gt;&lt;!-- ITEM_CENTER --&gt; &lt;div class ="item_right"&gt; &lt;img src="images/hamburgers.jpg" border="2" width="200px" height="150px"&gt;&lt;br/&gt; Hamburger w/ Fries - $7.00 &lt;input type="checkbox" name="check[]" value="Hamburger"&gt;&lt;br/&gt; &lt;/div&gt;&lt;!-- ITEM_RIGHT --&gt; </code></pre> <p><strong>PHP:</strong></p> <pre><code>&lt;?php if(isset($_POST['submit'])) { $to = "test@websitehere.com"; $subject = "Form Tutorial"; $name_field = $_POST['name']; $email_field = $_POST['email']; $message = $_POST['message']; $option = $_POST['radio']; $dropdown = $_POST['drop_down']; foreach($_POST['check'] as $value) { $check_msg .= "Checked: $value\n"; } $body = "From: $name_field\n E-Mail: $email_field\n $check_msg Option:$option\n Drop-Down: $dropdown\n Message:\n $message\n"; echo "Data has been submitted to $to!"; mail($to, $subject, $body); } else { echo "blarg!"; } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload