2016-11-26 97 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 –

相關問題