带有复选框的简单邮寄表格


Simple mailing form with check boxes

万物尊者代码,我是一个简单的平面设计师(甚至不是网页设计师),努力创建一个有效的邮件脚本。

到目前为止,我用基本的HTML和mailto函数完成了这项工作,但它需要在服务器端进行,所以,我猜PHP是我的最佳选择。

到目前为止,我拥有的是:

<form action="mailto:?subject=Hello" method="POST" enctype="text/plain">
<input type="checkbox" name="Entry1" value="URL1">
<input type="checkbox" name="Entry2" value="URL2">
<input type="checkbox" name="Entry3" value="URL3">
<input type="checkbox" name="Entry4" value="URL4">
<label for="name">Name</label><input type="text" id="name" name="name" placeholder="Your Name">
<label for="email">Email(Required)</label><input type="text" id="email" name="email" placeholder="john_doe@example.com" required class="inputfield">
<input type="submit" id="search-submit" value="">
</form>

我正在努力实现的目标:

  1. 要发送的电子邮件abc@email.com"电子邮件"字段和抄送321@email.com
  2. 带有消息和复选框(条目1、条目2…)中的值(URL1、URL2…)
  3. 如果成功,请重定向到感谢页面
<?php
if(isset($_POST['send'])){
 $_POST['email'];
 $_POST['name'];
 @$_POST['Entry1'];
 @$_POST['Entry2'];
 @$_POST['Entry3'];
@$_POST['Entry4'];
$to      =  $_POST['email'];
$subject = 'the subject';
$message = $_POST['name'] . @$_POST['Entry1'] . @$_POST['Entry2'] .   @$_POST['Entry3']    . @$_POST['Entry4'];
$headers = 'From:you@example.com';
mail($to, $subject, $message, $headers);
echo 'thanks you for your email';
header("where_you_want.php");
}else{
echo 'please try again';
}

?>

<form action="where_you_want.php" method="POST" enctype="text">
<input type="checkbox" name="Entry1" value="URL1">
<input type="checkbox" name="Entry2" value="URL2">
<input type="checkbox" name="Entry3" value="URL3">
<input type="checkbox" name="Entry4" value="URL4">
<label for="name">Name</label><input type="text" id="name" name="name"     placeholder="Your Name">
<label for="email">Email(Required)</label><input type="text" id="email" name="email" placeholder="john_doe@example.com" required class="inputfield">
<input type="submit" name="send" value="">

this is not the best answer but I test it and sending email with value and you can     change value and play around..I hope its help..

action="mailto:?subject=Hello"

这不是你想象的那样。

action指定目标URL。mailto:链接被发送到客户端,服务器不会对它们执行任何操作。

例如:

"mailto:mr.smith@matrix.com"
"http://www.domain.com"

mailto在这里类似于http


要使用PHP发送邮件,您可以使用mail函数或其他一些实现。表单中的action必须指向服务器上的脚本。