我有一個列表,它通過搜索完成。我想發送電子郵件給選定的人。我已經完成了編碼和功能,但仍然無法解決問題。請幫助我。PHP:在複選框中發送電子郵件
FORM:
<td align="left"><?php echo ucwords(stripslashes($row_list['nama'])); ?>
<td align="center"><input type="checkbox" name="txt_email_list" value="<?php echo $row_list['email']; ?>" /></td>
<td width="300" align="left">Send <a href="send_surat.php"><img src="images/email.png" width="24" height="24" border="0" align="absbottom"></td>
發送功能
$subject = 'Detail about u';
// message
$message = '
<html>
<head>
<title>Maklumat Majikan dan Tarikh Temuduga</title>
</head>
<body>
//message
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'From: JobsMalaysia Centre <[email protected]>' . "\r\n";
$headers .= 'Cc: [email protected]' . "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";
if(isset($_POST['total_email']) && is_array($_POST['total_email'])){
foreach($_POST['total_email'] as $to){
mail($to, $subject, $message, $headers);
}
}
else{
echo "No email addresses to send to!";
}
編輯:
<form action="send_surat.php" method="post" name="send_surat" class="search_form">
<td align="left"><?php echo ucwords(stripslashes($row_list['nama'])); ?></td>
<td align="center"><input type="checkbox" name="email"/>
<input type="hidden" name="total_email" id="total_email" value="<?php echo $row_list['email']; ?>"/></td>
<td><input type="submit" name="btn_email" id="btn_email" value="Send Email"/></td>
「它不鍛鍊」是非常無益的。嘗試添加一些細節。 – Blorgbeard
你只是連接到PHP頁面。您必須提交表格 – Cfreak
輸入需要用表格標籤包裝。而且,你不能傳遞一個帶有錨點標籤的表單變量。使用input type =「submit」來代替send_surat.php。 – dukedevil294