Basically, I'm trying to create an array, and send the array data to my email.
I'm still learning PHP, and am confused about how to set everything up properly.
If you have any advice that can get me started, I'd really appreciate it.
PHP
<?php
if (isset($_POST['submit'])) {
$to = "test@mywebsite.com";
$subject = "New Order";
$name_field = $_POST['name'];
$phone_field = $_POST['phone'];
foreach ($food as $key => $item) {
$body.= $key." - ".$item ["how_many"]
}
$food = array(
'mexican_torta' => array('how_many' => 2, 'customize' => NO),
'fish_sandwich' => array('how_many' => 0, 'customize' => 0)
)
);
echo $food['mexican_torta']['how_many'];
}
$body = "Name: $name_field\nPhone: $phone_field\nKey: $key\nItem $item"
echo "Data has been submitted to $to!";
mail($to, $subject, $body);
?>
HTML
<div class ="item">
<img style="float:left; margin-right:15px; border:1px Solid #000; width:200px; height:155px;" src="images/mexicantortas.jpg">
<h1>Mexican Torta - $8.50</h1>
<h2>How Many? <font color="#999999">Ex: 1, 2, 3...?</font></h2>
<input type='text' name='food[mexican_torta][how_many]'>
<h3>Customize It? <font color="#999999">Ex: No Lettuce, Extra Cheese...</font></h3>
<input type='text' name='food[mexican_torta][customize]'>
</div><!-- ITEM_LEFT -->
<div class ="item">
<img style="float:left; margin-right:15px; border:1px Solid #000; width:200px; height:155px;" src="images/fishsandwich.jpg">
<h1>Fish Sandwich - $8.50</h1>
<h2>How Many? <font color="#999999">Ex: 1, 2, 3...?</font></h2>
<input type='text' name='food[fish_sandwich][how_many]'>
<h3>Customize It? <font color="#999999">Ex: No Lettuce, Extra Cheese...</font></h3>
<input type='text' name='food[fish_sandwich][customize]'>
</div><!-- ITEM_LEFT -->