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?
$products = $_POST['product']; $orderedItems = "Ordered items:"; foreach($products as $product) { $orderedItems .= "$product "; } mail("your@email.com", "Subject line", $orderedItems);
You might need to set up a mail server, or you could use a service such as Mailgun .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.