0
我想創建一個網站一個簡單的服務請求的形式的身體。 意圖是讓用戶填寫表單,按提交按鈕,然後 生成一封發送給支持的電子郵件。PHP無法複選框可變信息添加到電子郵件
大多數形式的正常工作,但我不能複選框的值傳遞到電子郵件的正文。當我添加調試信息(使用回聲)時,我可以看到複選框變量已設置,但信息未傳遞到電子郵件信息 -
收到的信息 - 檢查複選框:修復損壞的鏈接,網頁需要更新,信息需要被添加到網頁
PHP代碼 -
<?php
if (isset($_POST['email'])) {
$admin_email = "[email protected]";
$email = $_POST['email'];
$subject = $_POST['subject'];
$selectedChecklist = 'None';
$body = "Information received--\n\n";
$comments = $_POST['comments'];
if(isset($_POST['check_list']) && is_array($_POST['check_list']) && count ($_POST['check_list']) > 0){
$selectedChecklist = implode(', ', $_POST['check_list']);
$body .= 'Checkboxes checked: ' . $selectedChecklist;
echo($body);
}
mail($admin_email, "$subject", $checklist, $body, $comments, "From:" . $email);
echo " Thank you for contacting us!";
}
else {
?>
// HTML form goes here
<?php
}
?>
HTML代碼form--
<form method="post">
Your Email: <input name="email" type="text" /><br />
<br />
Subject : <input name="subject" type="text" /><br />
<br />
What needs to be done?<br />
<input name="check_list[]" type="checkbox" value="Fix a broken link">Fix a broken link<br /><br />
<input name="check_list[]" type="checkbox" value="Information on a web page needs to be updated">Information on a web page needs to be updated<br /><br />
<input name="check_list[]" type="checkbox" value="Information needs to be added to a web page">Information needs to be added to a web page<br /><br />
Description:<br />
<textarea name="comments" rows="15" cols="40"></textarea><br />
<br />
<input type="submit" value="Submit" />