我有一个有多个选择选项的联系表格.但在提交联系表单后,电子邮件中只显示1个值.想找到解决方案来完成这项工作.
/ *我的代码开始* /
$title = $_POST['title'];
$contactperson = $_POST['contactperson'];
$phonenumber = $_POST['phonenumber'];
$emailaddress = $_POST['emailaddress'];
$companyname = $_POST['companyname'];
$brand = $_POST['brand'];
$machinemodel = $_POST['machinemodel'];
$serialnumber = $_POST['serialnumber'];
$problems = $_POST['problems'];
$inquiry = $_POST['inquiry'];
$security = $_POST['security'];
$from = "YT Copier";
$to = "mail@jornes.com";
$subject = "Admin, someone submitted service request form.";
$message = "Admin, someone has submitted service request form. Details are as follow: \n\nName: $title $contactperson\n\nPhone Number: $phonenumber\n\nEmail Address: $emailaddress\n\nCompany Name: $companyname\n\nMachine Brand:\n$brand\n\nMachine Model: $machinemodel\n\nSerial Number: $serialnumber\n\nProblem Facing: $problems\n\nMessage: $inquiry";
if ($security=="13") {
mail($to, $subject, $message, $from);
header("Location:/supports/submit-service-request/?s=s");
}
else {
header("Location:/supports/submit-service-request/?s=e");
}
< - HTML在这里开始 - >
Cannot Copy
Cannot Print
Cannot Scan
Cannot Fax
Lines Appear When Printing/Copying
Scan to Email Failed
Toner Low/Empty
Others
/ *代码结束* /
这是处理表单的文件名“process.php”中的php代码. “$problems”的值是一个多选项.我在填写表单时尝试选择一些选项,但最后,电子邮件中只显示了一个单一值.有人可以帮忙吗?我应该添加什么代码才能使其正常工作?真的很感激,如果有人可以帮忙.谢谢!
解决方法:
使用名称就像问题[]而不是问题
//Simple Form and getting the values
Cannot Copy
Cannot Print
Cannot Scan
Cannot Fax
Lines Appear When Printing/Copying
Scan to Email Failed
Toner Low/Empty
Others
if (isset($_POST['submit'])) {
$problems = implode(',', $_POST['problems']);
echo $problems;
}
?>
标签:contact-form,php
来源: https://codeday.me/bug/20191007/1863900.html