html - 如何让我的表单将提交内容发送到电子邮件?

标签 html css wordpress forms

如果这个问题已经被打死,我提前道歉,但我很难弄清楚如何让我的表格将提交内容发送到我的电子邮件地址。我试过在线查看所有内容,我看到的所有内容都是关于使用 html 和 css 格式化表单,但没有任何内容解释所涉及的脚本或需要如何设置它才能实际发送到电子邮件地址。

  <style>

  input[type=text], input[type=number], select[name=province]{ font-family: arial; width:100%;  
  border: 1px solid #E5E5E5; padding: 10px 20px;}
input[name=ffirstname] {width:49%; margin-right:1%; }
input[name=lastname] {width:49%; margin-left:1%; }
input[name=address] {width:65.6667%; margin-right:1%; }
input[name=unit] {width:32.3337%; margin-left:1%; }
input[name=city] {width:49%; margin-right:1%; }
select[name=province] {width:24%; margin-left:1%;}
input[name=postal] {width:24%; margin-left:1%; }
input[name=email] {width:49%; margin-right:1%; }
input[name=phone] {width:49%; margin-left:1%;}

input[class=submit] {

  background-color: #f05a28;
  color: white;
  padding: 8px 20px;
  margin-left: 85%;
  border-radius: 4px;
  border: none; !important;
  outline: none; !important ;
  cursor: pointer;
  box-shadow: none; !important;
 }
 </style>

 <form action method="post" enctype="multipart/form-data" name="frmhot" verified="0" id="huge_it_contact_form_3" class="hugeit_form">

  <br><input type="text" name="ffirstname" placeholder="First Name"/><input type="text" name="lastname" placeholder="Last Name"/>
  <br><br><input type="text" name="address" placeholder="Address"/><input type="text" name="unit" placeholder="Unit"/></br>
  <br><input type="text" name="city" placeholder="City"/><select name="province" form="form1">
<option value="ab">AB</option>
  <option value="BC">BC</option>
  <option value="BC">MB</option>
  <option value="NB">NB</option>
<option value="NL">NL</option>
<option value="NS">NS</option>
<option value="ON">ON</option>
<option value="PE">PE</option>
<option value="QC">QC</option>
<option value="SK">SK</option>
</select><input type="text" name="postal" placeholder="Postal Code"/></br>
<br><input type="text" name="country" placeholder="Country"/></br>
<Br><input type="text" name="email" placeholder="Email"/><input type="number" name="phone" placeholder="Phone#"/></br>
<br> <br><input class="submit" type="submit" value="Next" id="hugeit_preview_button__submit_21"/>

最佳答案

//using a sample html form as this below, i created a php script //that will perform this task`
<!DOCTYPE HTML>
<html>
<head>
    <title>Thank you</title>
</head>
<body>
<form name="contactform" method="post" action="form-to-email.php">
    <p>
        <label>Enter name : </label><br>
        <input type="text" name="name" required/>
    </p>
    <p>
        <label>Email address : </label><br>
        <input type="email" name="email" required/>
    </p>
    <p>
        <label>Message: </label><br>
        <textarea name="message" rows="3" cols="10" required></textarea>
    </p>
    <p>
        <input type="submit" name="submit" value="send"/>
    </p>

</form>
</body>
</html>

// then below is the php script called form-to-email.php
<html>
  <head>
    <title>form-to-email.php</title>
  </head>
 <body>
<?php

$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$to = "steloffs2006@gmail.com"; // your email address
$subject = "My contact form";   // the subject you want to see
$body = " You have received a new message from the user $name \n" ." Email address: $email \n" . " Here is the message: $message";
mail($to,$sub`enter code here`ject,$body);
echo "<h1>Thank you for your time </h1>";
?>
</body>
</html>

关于html - 如何让我的表单将提交内容发送到电子邮件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40814006/

相关文章:

php - 将产品简短描述添加到 WooCommerce 电子邮件通知

html - 需要通过 css 更改 html 值,如下所述。我使用的是wordpress,所以不好编辑核心文件

javascript - HTML Div 类不会将图像更改为新图像

javascript - iframe动态高宽根据内部内容变化

css - Meteor 包 accounts-ui-bootstrap-3 下拉菜单出现在屏幕外

php - get_permalink() 在循环期间返回重复的 URL

JavaScript 动态适应 A4 尺寸模板中的内容

javascript - 检测哪个选项卡/窗口在 Google Chrome 中被聚焦

javascript - 在 HTML5 中构建音频混合器

javascript - javascript生成内容的类选择器