简体   繁体   English

简单的电子邮件联系表格

[英]Simple email contact form

I am implementing a simple email input form into a splash page for submission. 我正在将一个简单的电子邮件输入表单实施到初始页面中以进行提交。

I know I need a post form, and have the html fully implemented (I think) per this: 我知道我需要一个张贴表格,并且对此有完全实现的html(我认为):

<div id="main">
    <form method="post" action="">
        <div id="text">
            Please enter your email address here, and we will get back to you
        </div>
        <input type="text" name="q" id="search" />
        <input type="submit" name="submit" id="submit" value="Go!" />
    </form>
</div>

My css follows as: 我的CSS如下:

#main input {
    margin: 30px auto auto 130px ;
    positiom: absolute;
    font-size: 18px;
    background: #fff;
    border: 3px;
    padding: 6px;
    z-index: 3;  
   }
#search {
    float: left;
    width: 550px;
   }
#submit {
    position: relative;
    width: 60px;
    margin: 130px auto auto 200px ;
   }
#submit::-moz-focus-inner { 
    border: 0;
    padding: 0;
}

I have a web server with apache, php, etc... installed and am trying to figure out the next step to finishing my form. 我有安装了apache,php等的网络服务器,并且正在尝试找出完成表单的下一步。 I would want this to function as a form that sends individual emails to a specific gmail account each time someone enters their address. 我希望此功能可以作为一种形式,在每次有人输入其地址时,将单个电子邮件发送到特定的gmail帐户。 Beyond a webserver, do I need additional tools to accomplish this? 除了网络服务器,我是否需要其他工具来完成此任务? I have read up on numerous sites about 3rd party forms that goes through their sites but am worried about the security and would rather have my site transfer all of the data. 我在许多站点上阅读了有关通过其站点进行的第三者表单的信息,但担心安全性,宁愿让我的站点传输所有数据。 Any help is much appreciated, thanks! 非常感谢任何帮助,谢谢!

You need a PHP script to handle sending the email. 您需要一个PHP脚本来处理发送电子邮件。 In your HTML, change the action: 在您的HTML中,更改操作:

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

And create a sendmail.php file with: 并使用以下命令创建一个sendmail.php文件:

<?php

$email = addcslashes($_REQUEST['q']) ;

mail( "yourname@example.com", "E-Mail entered",
"E-Mail entered: $email");
header( "Location: http://www.example.com/thankyou.html" );
?>

Edited: Added addclashes() 编辑:添加addclashes()

您是否考虑过使用PHPMailer?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM