使用您的文档复选框创建表单
<form method="post" action="test.php">
Document 1: <input type="checkbox" name="document[]" value="document1" /><br />
Document 2: <input type="checkbox" name="document[]" value="document2" /><br />
Document 3: <input type="checkbox" name="document[]" value="document3" /><br />
<br />
<input type="hidden" name="send" value="1" />
<input type="submit" value="Send" />
</form>
和一个 php 脚本来处理它
<?php
if(isset($_POST) && ($_POST['send'] == 1)){
$documents = array(
'document1' => 'http://www.example.com/document1.doc',
'document2' => 'http://www.example.com/document2.doc',
'document3' => 'http://www.example.com/document3.doc'
);
$to = 'nobody@example.com';
$subject = 'the subject';
$message = "hello\n\n";
if(isset($_POST['document']) && count($_POST['document']) > 0){
foreach($_POST['document'] as $doc){
if(isset($documents[$doc])){
$message .= "Here is ".$documents[$doc]."\n";
}
}
}
$headers = 'From: webmaster@example.com' . "\r\n" .
'Reply-To: webmaster@example.com' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
?>
我想你明白了。