网站表单发送到电子邮件

时间:2014-03-20 12:53:02

标签: php html forms

我是这方面的初学者,

我正在尝试查询表单中的信息并将其通过电子邮件发送到我的电子邮件地址。

获取表单的最简单方法是什么,

表单代码如下。我实际上在这个测试页面www.golfingholidays.ie/test.html

上玩了两种不同的形式

非常感谢任何帮助或建议

<div id="booking"></div>
<div id="book">
    <div id="top"></div>
    <div id="mid">  
        <div id="form">

            Name <input type="text" /><br />
            Telephone Number &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp;<input type="text" /><br />
            Email Address <input type="text" /><br />
            Address <input type="text"  /><br />

            Destination
            <select> 
                <option>Please Select</option>
                <option>Portugal</option>
                <option>Spain</option>
                <option>Tenerife</option>
                <option>Gran Canaria</option>
            </select>
            <br />

            Number of People 
            <select>
                <option>&nbsp;--&nbsp;</option>
                <option>&nbsp;01&nbsp;</option>
                <option>&nbsp;02&nbsp;</option>
                <option>&nbsp;03&nbsp;</option>
                <option>&nbsp;04&nbsp;</option>
                <option>&nbsp;05&nbsp;</option>
                <option>&nbsp;06&nbsp;</option>
                <option>&nbsp;07&nbsp;</option>
                <option>&nbsp;08&nbsp;</option>
                <option>&nbsp;09&nbsp;</option>
                <option>&nbsp;10+&nbsp;</option>
            </select>
            <br />

            Duration 
            <select>
                <option>&nbsp;--&nbsp;</option>
                <option>&nbsp;01&nbsp;</option>
                <option>&nbsp;02&nbsp;</option>
                <option>&nbsp;03&nbsp;</option>
                <option>&nbsp;04&nbsp;</option>
                <option>&nbsp;05&nbsp;</option>
                <option>&nbsp;06&nbsp;</option>
                <option>&nbsp;07&nbsp;</option>
                <option>&nbsp;08&nbsp;</option>
                <option>&nbsp;09+&nbsp;</option>
            </select>
            <br />

            Accom
            <select>
                <option>Please Select</option>
                <option>Apartments</option>
                <option>2** Hotel</option>
                <option>3*** Hotel</option>
                <option>4**** Hotel</option>
                <option>5***** Hotel</option>
            </select>

            <br />  Number of Rounds
            <select>
                <option>&nbsp;--&nbsp;</option>
                <option>&nbsp;01&nbsp;</option>
                <option>&nbsp;02&nbsp;</option>
                <option>&nbsp;03&nbsp;</option>
                <option>&nbsp;04&nbsp;</option>
                <option>&nbsp;05&nbsp;</option>
                <option>&nbsp;06&nbsp;</option>
                <option>&nbsp;07+&nbsp;</option>
            </select>

            <br />
            <div>Car Hire
                <input type="checkbox" name="Yes" value="Yes"/>Yes
                <input type="checkbox" name="no" value="no" />No
            </div>
            <br />

            Other <input type="text">
            <a id="button" href="#">Submit</a>
        </div>
    </div>
    <div id="bottom"></div>

</div>

2 个答案:

答案 0 :(得分:0)

例如

您的HTML页面

<!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 content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
    <title>send mail in php</title>  
    <style type="text/css">  
        li {list-style-type: none;  
            font-size: 16pt;  
        }  
        .mail {  
            margin: auto;  
            padding-top: 10px;  
            padding-bottom: 10px;  
            width: 400px;  
            background : #D8F1F8;  
            border: 1px solid silver;  
        }  
        .mail h2 {  
            margin-left: 38px;  
        }  
        input {  
            font-size: 20pt;  
        }  
        input:focus, textarea:focus{  
            background-color: lightyellow;  
        }  
        input submit {  
            font-size: 12pt;  
        }  
    </style>  
</head>  
<body>  
    <div class="mail">  
        <h2>Mail us</h2>  
        <ul>  
            <li><form name="mail" method="POST" action="send.php"></li>  
            <li>To:</li>  
            <li><input type="text" name="to" /></li>  
            <li>Subject:</li>  
            <li><input type="text" name="subject" /></li>  
            <li>Message:</li>  
            <li><input type="text" name="Message" /></li>  
            <li>&nbsp;</li>  
            <li><input type="submit" name="submit" value="Send"/></li>  
            <li>&nbsp;</li>  
            </form>  
        </ul>  
    </div>  
    </body>
</html>

处理表单(上面的代码)数据的文件代码

<?php  
    $to = $_POST['to'] ;      
    $message = $_POST['Message'] ;  
    mail( $to, "Mail", $message,  );  
    header( "Location: http://localhost/php/simple-mail.php" );  
?>

我希望这会给你一个想法

答案 1 :(得分:0)

如果您不想使用PHP,而只想使用HTML,则可以使用elFormo.com之类的服务。他们甚至有一个免费的计划。