我有一个带有复选框的基本表单,提交时将通过电子邮件发送给管理员(并复制给客户)。我的代码仅回显最后一个复选框(因此仅在电子邮件上显示一个复选框) - 我无法让它发送电子邮件中的所有复选框信息(即使在此处尝试了多个版本的代码之后)。
<form method="POST" name="contactform" action="include/contactstationcode.php">
<h1>Quick Contact Form</h1>
<p>
<section id="nameLabel" class="labelClass"><label id="Name">Full Name: </label><input name="name" id="name" size="30" class="inputField" type="text"><br></section>
<section id="nameLabel" class="labelClass"><label id="Student ID">Student ID: </label><input name="studentid" id="studentid" size="8" class="inputField" type="text"><br></section>
<section id="nameLabel" class="labelClass"><label id="Email">Email: </label><input name="email" id="email" size="30" class="inputField" type="text"><br></section>
<section id="nameLabel" class="labelClass"><label id="ContactNumber">Contact Number: </label><input name="contactnumber" id="contactnumber" size="30" class="inputField" type="text"><br></section>
<section id="nameLabel" class="labelClass"><label id="interests">Interests: <input type="checkbox" name="check_list[]" value="Presenting " checked> Presenting<br><input type="checkbox" name="check_list[]" value="Producing "> Producing<br><input type="checkbox" name="check_list[]" value="Audio Production ">Audio Production<br><input type="checkbox" name="check_list[]" value="Marketing "> Marketing<br><br><input type="checkbox" name="check_list[]" value="Web "> Web<br>
<section id="messageLabel" class="labelClass"><label>Relevant Experience:</label></section>
<section id="messageInput" class="inputClass"><textarea name="experience" id="experience" cols="30" rows="3"></textarea><br></section><br>
<section id="buttonClass" class="buttonClass"><input src="images/submit.png" onmouseover="this.src='images/submit2.png'" onmouseout="this.src='images/submit.png'" alt="submit" value="submit" height="25" type="image" width="70"></section>
</p>
</form>
我拥有的 PHP 脚本是:
<?php date_default_timezone_set('Europe/London');
$from = 'From: company@company.com';
$today = date('l, F jS Y.');
$to = 'secret@secret.com';
//Form Fields
$name = $_POST['name'];
$studentid = $_POST['studentid'];
$email = $_POST['email'];
$contactnumber = $_POST['contactnumber'];
$experience = $_POST['experience'];
if(!empty($_POST['check_list'])) {
foreach($_POST['check_list'] as $check) {
$check=$check.',';
}
}
//Admin Email Body
$subject = 'ClickTeesside.com Get Involved Request';
$bodyp1 = "You have received a Get Involved Request through the ClickTeesside website on $today \n\nFrom: $name ($studentid)\nEmail Address: $email\nContact Number: $contactnumber";
$bodyp2 = "\n\nInterests include: ".$check;
$bodyp3 = "\n\nPrevious Experience: $experience";
$bodyp4 = "\n\nIf suitable, please get in touch with this candidate as soon as possible - the candidate has also received an automated response.";
$body=$bodyp1.$bodyp2.$bodyp3.$bodyp4;
mail ($to, $subject, $body, $from);
//Candidate Email
$candidatesubject = 'ClickTeesside.com Get Involved: Automated Email';
$candidatefrom = 'From: ClickTeesside.com';
$cbody = "Thank you for emailing Click Radio about becoming involved with the station.\nWe've sent your details to our Station Management, who will review your application.\nIf successful, we will contact you in due course.\n\n";
$cbody2 = "Here is a copy of what you sent to us on $today:\n\nName: $name ($studentid)\nEmail Address: $email\nContact Number: $contactnumber\nSpecified Interested Areas: ".$check."\n\nPrevious Experience: $experience";
$candidatebody = $cbody.$cbody2;
mail ($email, $candidatesubject, $candidatebody, $from);
header("Location: http://www.google.co.uk/");
?>
看不到我哪里出错了 - 所以如果你能指出我正确的方向:) 谢谢!