我有一张表格。我喜欢用PHP脚本发送这个表。它应该列出所有选中的复选框,它们都有一个独特的产品。 (在value-atribute中)和select字段来选择数量。
我如何在邮件中实现这种结构:
姓名:John Doe XVV
电子邮件:xyz@xyz.com
产品:(来自价值:) 142547或类似的......
Stückzahl:(来自选择)5
产品:1414 ......
Stückzahl:12
产品:14258-UI ......
Nachricht: 喂...
每个表格行都有简单的描述,最后有两个fiels:
<select class="1-100" name="menge[]" value="Stueckzahl"></select> <input type="checkbox" name="checkboxes[]" value="14258-UI">
这是我的php
$submitted = sanitize_text_field( $_POST['scf_submitted'] );
$name = sanitize_text_field( $_POST['scf_name'] );
$email = sanitize_text_field( $_POST['scf_email'] );
$message = sanitize_text_field( $_POST['scf_message'] );
$honeypot = $_POST['scf_message2'];
//$product = sanitize_text_field( $_POST['checkboxes'] );//
//$quantity = sanitize_text_field( $_POST['menge'] );//
$product = implode(' ', $_POST['checkboxes'] );
$quantity = implode(' ', $_POST['menge'] );
$body = "Name: $name \n\nE-Mail: $email \n\nProdukt: $product \n\nStückzahl: $quantity \n\nNachricht: \n$message";
我希望有人可以帮助我 - 谢谢
答案 0 :(得分:0)
你可以通过在php处理程序上迭代表单行来实现,比如;
<?php
// You need to do some sanitization for posted fields
.............
$propArr = array(
"menge" => "Menge",
"checkbox" => "Checkbox",
"other_attr" => "Other Attribute"
);
$html = "";
foreach($_POST["menge"] as $key => $val) {
foreach($propArr as $k => $v) {
$html .= "\n\n".$propArr[$k].":".$_POST[$k][$key];
}
}
$body = $html;
?>