2016-11-26 91 views
0

如果这个问题已经被殴打致死,我很抱歉,但我很难弄清楚如何让我的表单发送给我的电子邮件地址。我尝试过在网上查找,我看到的所有内容都是关于使用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

的[如何从在WordPress形式发送邮件]可能的复制(http://stackoverflow.com/questions/10927682/how-to - 发送电子邮件从形式在wordpress) – Ouroborus

+0

HTML不会做电子邮件,你必须脚本(PHP,Perl的,无论...)的形式提交给自己,或到另一个页面,然后让它处理帖子请求,获取值和重要的VALIDATE以避免任何讨厌的u表格的se,然后让它发送电子邮件。例如,PHP具有mail(),它接受主题,主体,参数等。你的表单CSS等与这个过程无关,这只是样式和布局,与脚本发送电子邮件无关。 – Lizardx

+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 = "[email protected]"; // 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>

+0

我仍然有麻烦,因为我使用的是女ress相我发现我必须使用PHP的解决方法,所以我使用的插件“PHP代码snipets”,它允许我插入简码php ive在我的页面上的一个小部件中写了一个调用它。该文件的名称是“formsend.php”,我把它放到窗体的“action”字段中,但它看起来并没有看到电子邮件仍然在发送“

' –

+0

'$ name = $ _POST ['ffirstname']; $ email = $ _POST ['lastname']; $ message = $ _POST ['address']; $ to =“[email protected]”; $ subject =“我的联系表”; ($ to,$ subject,$ body);'$ message“;” $ body =“您收到了来自用户$ name的新消息以下是消息:$ message”;“ mail –

相关问题