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

时间:2016-11-26 01:11:04

标签: 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"/>

1 个答案:

答案 0 :(得分:0)

//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>