Reputation: 103
I have multiple inputs with the same Name attribute and different Values, which cannot be changed by the user.
<form action="../scripts/sc_order.php" method="post">
<div class="sc_content">
<input type="text" name="product[]" value="Potato" readonly/>
<input type="text" name="product[]" value="Tomato" readonly/>
<input type="text" name="product[]" value="Banana" readonly/>
<input type="text" name="product[]" value="Orange" readonly/>
</div>
<input type="submit" value="Submit" />
</form>
The inputs are added to the form and they serve as an identifier for the product which the user has added. When the user submits the form, I should get an email with the list of values the user has selected. How do I achieve this in PHP?
Upvotes: 1
Views: 2575
Reputation: 189
$products = $_POST['product'];
$orderedItems = "Ordered items:";
foreach($products as $product) {
$orderedItems .= "$product ";
}
mail("[email protected]", "Subject line", $orderedItems);
You might need to set up a mail server, or you could use a service such as Mailgun.
Upvotes: 2