使用“提交”按钮将表单数据发送到电子邮件

时间:2016-06-01 23:12:54

标签: html submit mailto

我在互联网上浏览并创建了这份共识表格。布局和一切都是我想要的。我喜欢做的是当用户点击提交按钮时,我希望将表单的内容发送到电子邮件,例如somemail@mail.com

任何人都可以帮助我。这对我来说非常有用。谢谢

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GoodJob - BadJob - Tenerife</title>
<link rel="stylesheet" type="text/css" href="view.css" media="all">
<script type="text/javascript" src="view.js"></script>

</head>
<body id="main_body" >

    <img id="top" src="top.png" alt="">
    <div id="form_container">

        <h1><a>Good - Bad - hmm</a></h1>
        <form id="form_1136056" class="appnitro"  method="post" action="">
                    <div class="form_description">
            <h2>GoodJob - BadJob - Tenerife</h2>
            <p>It's Anonymous. Keep the information REAL. Don't make things up. If anything is EVER going to change, it needs to be REAL information. This form will be sent to an email address and will then be posted Anonymously on Facebook for you.</p>
    </div>                      
            <ul >

                    <li id="li_1" >
    <label class="description" for="element_1">What is the Alias you want to use </label>
    <div>
            <input id="element_1" name="element_1" class="element text medium" type="text" maxlength="255" value=""/> 
        </div><p class="guidelines" id="guide_1"><small>You don't have to use your real name - Just remember your Alias for Facebook Comments</small></p> 
        </li>       <li id="li_8" >
        <label class="description" for="element_8">Is this about a ...... </label>
        <span>
            <input id="element_8_1" name="element_8" class="element radio" type="radio" value="1" />
<label class="choice" for="element_8_1">Bad job</label>
<input id="element_8_2" name="element_8" class="element radio" type="radio" value="2" />
<label class="choice" for="element_8_2">Good Job</label>

        </span> 
        </li>       <li id="li_6" >
        <label class="description" for="element_6">What is the name of the workplace you want to tell us about? </label>
        <div>
            <input id="element_6" name="element_6" class="element text medium" type="text" maxlength="255" value=""/> 
        </div><p class="guidelines" id="guide_6"><small>Type in the Name of the Business</small></p> 
        </li>       <li id="li_16" >
        <label class="description" for="element_16">Where is this Business Located? </label>
        <div>
        <input id="element_16" name="element_16" class="element text medium" type="text" maxlength="255" value=""/> 
        </div><p class="guidelines" id="guide_16"><small>Type in the town, or you can find the business on google maps and click on share and copy the link and paste it here.</small></p> 
        </li>       <li id="li_7" >
        <label class="description" for="element_7">If you want to mention the bosses name, Put it here. </label>
        <div>
            <input id="element_7" name="element_7" class="element text medium" type="text" maxlength="255" value=""/> 
        </div><p class="guidelines" id="guide_7"><small>Type in the Name of the Boss</small></p> 
        </li>       <li id="li_15" >
        <label class="description" for="element_15">If you know the personal facebook page you can copy and paste it in here </label>
        <div>
            <input id="element_15" name="element_15" class="element text large" type="text" maxlength="255" value=""/> 
        </div><p class="guidelines" id="guide_15"><small>Go to the top address bar of the boss/owner  you want to tag for this post. Select all the text and paste it in the box.</small></p> 
        </li>       <li id="li_9" >
        <label class="description" for="element_9">How many hours a week do you work? </label>
        <span>
            <input id="element_9_1" name="element_9" class="element radio" type="radio" value="1" />
<label class="choice" for="element_9_1">1 to 10</label>
<input id="element_9_2" name="element_9" class="element radio" type="radio" value="2" />
<label class="choice" for="element_9_2">10 to 20</label>
<input id="element_9_3" name="element_9" class="element radio" type="radio" value="3" />
<label class="choice" for="element_9_3">20 to 30</label>
<input id="element_9_4" name="element_9" class="element radio" type="radio" value="4" />
<label class="choice" for="element_9_4">30 to 40</label>
<input id="element_9_5" name="element_9" class="element radio" type="radio" value="5" />
<label class="choice" for="element_9_5">40 to 50</label>
<input id="element_9_6" name="element_9" class="element radio" type="radio" value="6" />
<label class="choice" for="element_9_6">50 hours Plus</label>

        </span><p class="guidelines" id="guide_9"><small>Keep it REAL.     </small></p> 
        </li>       <li id="li_18" >
        <label class="description" for="element_18">Exactly how many hours do you work? </label>
        <div>
            <input id="element_18" name="element_18" class="element text medium" type="text" maxlength="255" value=""/> 
        </div> 
        </li>       <li id="li_11" >
        <label class="description" for="element_11">Does your Job Pay Extra Hours? </label>
        <span>
            <input id="element_11_1" name="element_11" class="element radio" type="radio" value="1" />
<label class="choice" for="element_11_1">Yes</label>
<input id="element_11_2" name="element_11" class="element radio" type="radio" value="2" />
<label class="choice" for="element_11_2">No</label>

        </span> 
        </li>       <li id="li_10" >
        <label class="description" for="element_10">What type of contract do you have? </label>
        <span>
            <input id="element_10_1" name="element_10" class="element radio" type="radio" value="1" />
<label class="choice" for="element_10_1">Part Time</label>
<input id="element_10_2" name="element_10" class="element radio" type="radio" value="2" />
<label class="choice" for="element_10_2">Full Time</label>
<input id="element_10_3" name="element_10" class="element radio" type="radio" value="3" />
<label class="choice" for="element_10_3">Hourly per week</label>
<input id="element_10_4" name="element_10" class="element radio" type="radio" value="4" />
<label class="choice" for="element_10_4">Dont know</label>

        </span><p class="guidelines" id="guide_10"><small>DON'T GUESS..This is crucial. Every worker MUST have a copy of their contract. If you don't have one ask your boss or go to the Employment office (SEPE) with ALL your credentials and they will tell you there what contract you have.</small></p> 
        </li>       <li id="li_12" >
        <label class="description" for="element_12">Did you get Holiday pay? </label>
        <span>
            <input id="element_12_1" name="element_12" class="element radio" type="radio" value="1" />
<label class="choice" for="element_12_1">Yes</label>
<input id="element_12_2" name="element_12" class="element radio" type="radio" value="2" />
<label class="choice" for="element_12_2">No</label>

        </span> 
        </li>       <li id="li_17" >
        <label class="description" for="element_17">How much holiday pay did you get? </label>
        <div>
            <input id="element_17" name="element_17" class="element text medium" type="text" maxlength="255" value=""/> 
        </div><p class="guidelines" id="guide_17"><small>A NUMBER ONLY no symbols or text</small></p> 
        </li>       <li id="li_13" >
        <label class="description" for="element_13">Did you know That there are actually 14 months in a Spanish working year? </label>
        <span>
            <input id="element_13_1" name="element_13" class="element radio" type="radio" value="1" />
<label class="choice" for="element_13_1">Yes</label>
<input id="element_13_2" name="element_13" class="element radio" type="radio" value="2" />
 <label class="choice" for="element_13_2">No</label>

        </span><p class="guidelines" id="guide_13"><small>Its true, In Spain ins a 14 month pay scheme, where you get a double pay in summer and another Christmas. Most employers will actually incorporate these two payments within your monthly wage...Meaning you get less :)</small></p> 
        </li>       <li id="li_14" >
        <label class="description" for="element_14">Got a story to tell about this Job? Bad or good - let it rip here!</label>
        <div>
            <textarea id="element_14" name="element_14" class="element textarea large"></textarea> 
        </div> 
        </li>

                    <li class="buttons">
                <input type="hidden" name="form_id" value="1136056" />

                <input id="saveForm" class="button_text" type="submit" name="Submit" value="Submit" />
        </li>
            </ul>
        </form> 
        <div id="footer">
            Copyright Goodjob-BadJob - Visit the facebook page  <a href="https://www.facebook.com/groups/xxxxxxxxxxxxxxxxx/" target="new">CLICK HERE</a>
        </div>
    </div>
    <img id="bottom" src="bottom.png" alt="">
    </body>
</html>

2 个答案:

答案 0 :(得分:2)

使用php.redirect操作到服务器中的php文件。例如mail.php

<form method="post" action="mail.php">

并在php文件中使用这些

<?php 
$element1 = $_POST['element_1'];
$element8 = $_POST['element_8'];
$element6 = $_POST['element_6'];

$formcontent="From: $element1 \n Message: Is this about a $element81, Where is this Business Located? element6, blah blah blah";
$recipient = "youremail@email.com";
$subject = "Contact Form";
$mailheader = "From: $element1 \r\n";
mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
echo "<script type='text/javascript'>alert('Mail sent successfully!')</script>";
?>

并从表单中添加字段。我刚加了一些。根据需要编辑formcontent消息。

答案 1 :(得分:0)

添加到action mailto:youremailaddress.com

为您的例子 -

form id="form_1136056" class="appnitro" method='post' action='mailto:youremailaddres.whatever?Subject=whatever' ENCTYPE="text/plain"