Pls i have a challenge in which i need your assistance. I have a product place order form where customers select the product they want from a list, enter the amount, the quantity and select the measurement. By submitting this form, i want the items submitted to be sent into my mail. This is my code below;
order-product.php
[text]
<form name="form1" method="post" action="">
Name: <input name="name1" type="text" class="input" id="name1" value="<?php echo $name1; ?>" maxlength="50">
Address: <input name="address1" type="text" class="input" id="address1" value="<?php echo $address1; ?>" maxlength="100">
<table width="90%" border="0" cellpadding="3" cellspacing="0" class="border">
<tr>
<td width="8%" align="center" valign="middle" bgcolor="#666666" class="style1"> </td>
<td width="40%" align="center" valign="middle" bgcolor="#666666" class="style1"><strong>Products</strong></td>
<td width="20%" align="center" valign="middle" bgcolor="#666666" class="style1"><strong>Amount ($) </strong></td>
<td colspan="2" align="center" valign="middle" bgcolor="#666666" class="style1"><strong>Quantity</strong></td>
</tr>
<tr>
<td align="center" valign="middle" class="border_bottom"><label>
<input name="product[1]" type="checkbox" id="product[1]" value="Beans">
</label></td>
<td align="left" valign="middle" class="border_bottom">Beans</td>
<td align="center" valign="middle" bgcolor="#E3FBE1" class="border_bottom"><label>
<input name="amount1" type="text" class="input2" id="amount1" size="9">
</label></td>
<td width="16%" align="center" valign="middle" class="border_bottom">
<select name="measure1" class="input2" id="measure1">
<option selected="selected" value="" <?php if (!(strcmp("", $measure))) {echo "selected=\"selected\"";} ?>>Select</option>
<option value="Litres" <?php if (!(strcmp("Litres", $measure))) {echo "selected=\"selected\"";} ?>>Litres</option>
<option value="Kg" <?php if (!(strcmp("Kg", $measure))) {echo "selected=\"selected\"";} ?>>Kg</option>
<option value="Lb" <?php if (!(strcmp("Lb", $measure))) {echo "selected=\"selected\"";} ?>>Lb</option>
</select> </td>
<td width="16%" align="center" valign="middle" class="border_bottom">
<input name="qty1" type="text" class="input2" id="qty1" value="" size="9"> </td>
</tr>
<tr>
<td align="center" valign="middle" class="border_bottom"><input name="product[2]" type="checkbox" id="product[2]" value="Breadfruith"></td>
<td align="left" valign="middle" class="border_bottom">Breadfruith</td>
<td align="center" valign="middle" bgcolor="#E3FBE1" class="border_bottom"><input name="amount2" type="text" class="input2" id="amount2" size="9"></td>
<td align="center" valign="middle" class="border_bottom"><select name="measure2" class="input2" id="measure2">
<option selected="selected" value="" <?php if (!(strcmp("", $measure))) {echo "selected=\"selected\"";} ?>>Select</option>
<option value="Litres" <?php if (!(strcmp("Litres", $measure))) {echo "selected=\"selected\"";} ?>>Litres</option>
<option value="Kg" <?php if (!(strcmp("Kg", $measure))) {echo "selected=\"selected\"";} ?>>Kg</option>
<option value="Lb" <?php if (!(strcmp("Lb", $measure))) {echo "selected=\"selected\"";} ?>>Lb</option>
</select></td>
<td align="center" valign="middle" class="border_bottom"><input name="qty2" type="text" class="input2" id="qty2" size="9"></td>
</tr>
<tr>
<td align="center" valign="middle" class="border_bottom"><input name="product[3]" type="checkbox" id="product[3]" value="Cocoyam Flour"></td>
<td align="left" valign="middle" class="border_bottom">Cocoyam Flour</td>
<td align="center" valign="middle" bgcolor="#E3FBE1" class="border_bottom"><input name="amount3" type="text" class="input2" id="amount3" size="9"></td>
<td align="center" valign="middle" class="border_bottom"><select name="measure3" class="input2" id="measure3">
<option selected="selected" value="" <?php if (!(strcmp("", $measure))) {echo "selected=\"selected\"";} ?>>Select</option>
<option value="Litres" <?php if (!(strcmp("Litres", $measure))) {echo "selected=\"selected\"";} ?>>Litres</option>
<option value="Kg" <?php if (!(strcmp("Kg", $measure))) {echo "selected=\"selected\"";} ?>>Kg</option>
<option value="Lb" <?php if (!(strcmp("Lb", $measure))) {echo "selected=\"selected\"";} ?>>Lb</option>
</select></td>
<td align="center" valign="middle" class="border_bottom"><input name="qty3" type="text" class="input2" id="qty3" size="9"></td>
</tr>
</table>
<input name="Order" type="submit" class="submit" id="Order" value="Submit">
[/text]
Below is how i have tried to loop the result;
Code: Select all
if(isset($_POST[Order])){
$name = $_POST[name];
$address = $_POST[address];
for($i=1; $i<=3; $i++){
$product = $_POST["product".$i];
$amount = $_POST["amount".$i];
$qty = $_POST["qty".$i];
$measure = $_POST["measure".$i];
}
foreach(($product as $pro), ($amount as $amo), ($qty as $q)){
}
Bean, $50, 20kg
Breadfruit, $20, 5kg
How do i compose the message to be sent this with his/her name and address? Below this is how i did it but its not giving me what i want
Code: Select all
$msg = "Customer Name: $name\n\nAddress $address\n\nProduct: $product\nAmount: $amount\n$Quantity: $qty $measure";
mail ('my@email.com', 'ORDER', '$msg')