简体   繁体   English

HTML 联系我们表格

[英]HTML Contact Us form

I have a template of a contact us form which is at the bottom of each webpage.我有一个联系我们表格的模板,它位于每个网页的底部。 When the user enters there details I want it to send the message to my designated email address and also a notification to the user that it has been sent successfully (Just a simple internet popup)当用户输入详细信息时,我希望它将消息发送到我指定的电子邮件地址,并向用户发送成功发送的通知(只是一个简单的互联网弹出窗口)

    <div id="contact" class="contact">
            <div class="container">
            <div class="contact-grids">
                <div class="col-md-6">
                    <div class="contact-left wow fadeInRight" data-wow-delay="0.4s">
                        <h3>Contact Us</h3>
                        <label>Please contact us if you require one of our solutions. All enquiries and quotes are free of service.   </label>        <label><img src="images/icons/phoneicon.png" width="50px" /> (028) 900 00 00</label>
                        <label><img src="images/icons/emailicon.png" width="50px" />example@gmail.com</label>
                        <label><img src="images/icons/openinghoursicon.png" width="50px" />Monday - Friday (9am - 4pm)</label>

                        <div class="contact-left-grids">

                            <div class="clearfix"> </div>
                        </div>
                    </div>
                </div>
                <div class="col-md-6">
                    <div class="contact-right wow fadeInLeft" data-wow-delay="0.4s">
                        <form>
                            <input type="text" class="text" value="Name..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name...';}">
                            <input type="text" class="text" value="Email..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email...';}">
                            <textarea value="Message:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message';}">Message..</textarea>
                            <a class="leran-more" href="#">Submit</a></div>
                        </form>
                    </div>
                </div>
                <div class="clearfix"> </div>
            </div>

            <!--- copy-right ---->
            <br>
                <p> &nbsp;&copy; copyright</a></p>
                <script type="text/javascript">
                                $(document).ready(function() {
                                    /*
                                    var defaults = {
                                        containerID: 'toTop', // fading element id
                                        containerHoverID: 'toTopHover', // fading element hover id
                                        scrollSpeed: 1200,
                                        easingType: 'linear' 
                                    };
                                    */

                                    $().UItoTop({ easingType: 'easeOutQuart' });

                                });
                            </script>
                                <a href="#" id="toTop" style="display: block;"> <span id="toTopHover" style="opacity: 1;"> </span></a>

            <!--- copy-right ---->
        </div>
        </div>
        <!---- contact --->

To show a popup box all you need to do is add alert("Email Sent");要显示一个弹出框,您只需添加alert("Email Sent"); to your javascript code到您的 javascript 代码

As far as sending email goes, that is server side and depends on your configuration a bit.至于发送电子邮件,那是服务器端,有点取决于您的配置。 Do you have any code or a starting point?你有任何代码或起点吗?

As mentioned in the comment above, you will generally need some sort of backend (runs on your server) to send email.正如上面的评论中提到的,您通常需要某种后端(在您的服务器上运行)来发送电子邮件。 Which one to use depends on your server setup but there are many available.使用哪一个取决于您的服务器设置,但有很多可用。 In general, you'll probably set up a form/ajax to submit the data from your web page to the server which will send out the mail.通常,您可能会设置一个表单/ajax 来将数据从您的网页提交到将发送邮件的服务器。

You could do a simple web search for a mail script or use some simple PHP (assuming your server supports it) to send the email:您可以对邮件脚本进行简单的网络搜索或使用一些简单的 PHP(假设您的服务器支持它)来发送电子邮件:

<?php 
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];

$body = "\"{$name}\" <{$email}> sent you a message!\n\n{$message}";

mail("you@yourdomain.com", "Some subject", $body, "From: {$email}");
?>

You would the need to modify your form to submit it您需要修改您的表单以提交它

<form method="POST" action="/path/to/mailer.php">
  <input type="text" class="text" value="Name..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Name...';}" name="name">
  <input type="text" class="text" value="Email..." onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Email...';}" name="email">
  <textarea value="Message:" onfocus="this.value = '';" onblur="if (this.value == '') {this.value = 'Message';}" name="message">Message..</textarea>
  <a class="learn-more" href="#">Submit</a></div>
</form>

Similarly for a notification, you could find one of numerous libraries that provide nice styled overlays or go with a simple alert("your message here");同样,对于通知,您可以找到众多提供漂亮样式覆盖或带有简单alert("your message here"); in JavaScript on your submission page.在您提交页面上的 JavaScript 中。 Since, by default, form submission redirects the user to the submission page, could also just display a message inline HTML there.由于默认情况下,表单提交会将用户重定向到提交页面,因此也可以只在那里显示内联 HTML 消息。

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

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