0
我有一個非常通用的形式。我希望用戶輸入他們的電子郵件地址,選擇他們希望收到的任何文件,並希望通過下載鏈接生成他們所選文件的電子郵件。我過去做過這件事,但我的想法一片空白。您可以提供的任何幫助表示讚賞!謝謝。發送電子郵件到表單用戶與文檔鏈接
這裏的部份形式:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0
Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>My Form</title>
</head>
<body>
<form method="post" action="autoreply.php">
<label class="description" for="email">Your Email Address</label>
<input id="email" name="email" class="element text medium" type="text" maxlength="255" value=""/>
<br />
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="Submit" />
</form>
</body>
</html>
這裏是我的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 = '$email';
$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: [email protected]' . "\r\n" .
'Reply-To: [email protected]' . "\r\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
}
?>