• <legend id='Y6K7h'><style id='Y6K7h'><dir id='Y6K7h'><q id='Y6K7h'></q></dir></style></legend>

        • <bdo id='Y6K7h'></bdo><ul id='Y6K7h'></ul>
      1. <tfoot id='Y6K7h'></tfoot>

        <small id='Y6K7h'></small><noframes id='Y6K7h'>

        <i id='Y6K7h'><tr id='Y6K7h'><dt id='Y6K7h'><q id='Y6K7h'><span id='Y6K7h'><b id='Y6K7h'><form id='Y6K7h'><ins id='Y6K7h'></ins><ul id='Y6K7h'></ul><sub id='Y6K7h'></sub></form><legend id='Y6K7h'></legend><bdo id='Y6K7h'><pre id='Y6K7h'><center id='Y6K7h'></center></pre></bdo></b><th id='Y6K7h'></th></span></q></dt></tr></i><div id='Y6K7h'><tfoot id='Y6K7h'></tfoot><dl id='Y6K7h'><fieldset id='Y6K7h'></fieldset></dl></div>

        PHP 联系表单的配置问题

        时间:2024-04-12

              <tbody id='WPzyF'></tbody>

            <i id='WPzyF'><tr id='WPzyF'><dt id='WPzyF'><q id='WPzyF'><span id='WPzyF'><b id='WPzyF'><form id='WPzyF'><ins id='WPzyF'></ins><ul id='WPzyF'></ul><sub id='WPzyF'></sub></form><legend id='WPzyF'></legend><bdo id='WPzyF'><pre id='WPzyF'><center id='WPzyF'></center></pre></bdo></b><th id='WPzyF'></th></span></q></dt></tr></i><div id='WPzyF'><tfoot id='WPzyF'></tfoot><dl id='WPzyF'><fieldset id='WPzyF'></fieldset></dl></div>
          1. <tfoot id='WPzyF'></tfoot>
              • <bdo id='WPzyF'></bdo><ul id='WPzyF'></ul>

                <small id='WPzyF'></small><noframes id='WPzyF'>

                <legend id='WPzyF'><style id='WPzyF'><dir id='WPzyF'><q id='WPzyF'></q></dir></style></legend>
                1. 本文介绍了PHP 联系表单的配置问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 StackOverflow 上看到了许多与我的问题相似的问题,但我想我还没有找到正确的解决方案.

                  I have seen that there are many similar to mine questions here on StackOverflow, but I think I was not able to find the correct solution to my question yet.

                  我遇到的问题与接收电子邮件功能有关 - 基本上是网站的 联系我们 部分,用户可以在其中填写基于 html 的表单并按 <代码>发送消息,此消息将发送到我的电子邮件.

                  The problem what I am having is connected with receiving emails functionality - basically a contact us section of the website, where user can fill in html based form and press send message and this message will be delivered to my email.

                  我使用 XAMPP 进行开发,并在 localhost 上运行 Apache 服务器和 Mercury.即使验证显示成功 - 电子邮件也无法通过.

                  I do my development using XAMPP and running the Apache server and Mercury on localhost. Even though validation shows success - emails do not get through.

                  1. 我尝试将 method="post" 添加到 HTML 部分,但发现 type: "POST" 已包含在内.
                  2. 仔细检查 Mercury 使用的端口,并将其与 php.ini 中提到的端口进行比较,两者都设置为 25.
                  3. 我也尝试部署到 Bitbucket 页面 和 Azure 从本地主机迁移到实时托管.
                  1. I have tried to add method="post" to HTML section, but found out that type: "POST" is already included.
                  2. Double checked what port Mercury uses and compared it with the one mentioned in php.ini both are set to 25.
                  3. I have also tried to deploy to Bitbucket pages and Azure to move from localhost to live hosting.

                  我已经仔细阅读了这篇非常详细的帖子.将网站上传到实时托管的想法来自这篇文章.

                  I have carefully read through this very detailed post. The idea to upload the website to live hosting came from this post.

                  <?php
                  $name = trim($_POST['name']);
                  $email = trim($_POST['email']);
                  $message = trim($_POST['message']);
                  
                  
                  if( isset($name) && isset($email) ) {
                  
                      // Avoid Email Injection and Mail Form Script Hijacking
                      $pattern = "/(content-type|bcc:|cc:|to:)/i";
                      if( preg_match($pattern, $name) || preg_match($pattern, $email) || preg_match($pattern, $message) ) {
                          exit;
                      }
                  
                      $to = "myemail@gmail.com";
                      $sub = "$name from Cv";
                      // HTML Elements for Email Body
                      $body = <<<EOD
                      <strong>Name:</strong> $name <br>
                      <strong>Email:</strong> <a href="mailto:$email?subject=feedback" "email me">$email</a> <br> <br>
                      <strong>Message:</strong> $message <br>
                  EOD;
                  
                      $headers = "From: $name <$email>
                  ";
                      $headers .= 'MIME-Version: 1.0' . "
                  ";
                      $headers .= 'Content-type: text/html; charset=iso-8859-1' . "
                  ";
                  
                      mail($to, $sub, $body, $headers);
                  }
                  
                  ?>
                  

                  $("#contact-form-1").submit(function(e) {
                    e.preventDefault();
                    var success = $(this).find('.email-success'),
                        failed = $(this).find('.email-failed'),
                        loader = $(this).find('.email-loading'),
                        postUrl = $(this).attr('action');
                  
                    success.fadeOut(100); failed.fadeOut(100); loader.fadeOut(100);
                  
                    var data = {
                      name: $(this).find('.contact-name').val(),
                      email: $(this).find('.contact-email').val(),
                      message: $(this).find('.contact-message').val()
                    };
                  
                    if ( isValidEmail(data['email']) && (data['message'].length > 1) && (data['name'].length > 1) ) {
                      $.ajax({
                        type: "POST",
                        url: postUrl,
                        data: data,
                        beforeSend: function() {
                          loader.fadeIn(500);
                        },
                        success: function(data) {
                          loader.fadeOut(500);
                          failed.fadeOut(500);
                          success.delay(500).fadeIn(500);
                        },
                        error: function(xhr) { // if error occured
                          loader.fadeOut(500);
                          success.fadeOut(500);
                          failed.delay(500).fadeIn(500);
                        },
                        complete: function() {
                          loader.fadeOut(500);
                        }
                      });
                    } else {
                      loader.fadeOut(500);
                      failed.delay(500).fadeIn(500);
                      success.fadeOut(500);
                    }
                  
                    return false;
                  });

                  <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
                  
                  <form id="contact-form-1" action="sendmail.php" method="POST">
                    
                    <input class="contact-name form-control" type="text" name="name" placeholder="FULL NAME">
                    <input class="contact-email form-control" type="text" name="email" placeholder="EMAIL">
                    <textarea class="contact-message form-control" name="message" placeholder="MESSAGE" rows="5"></textarea>
                    <button class="btn">SEND MESSAGE</button>
                  
                  </form>

                  注意:此代码不是我自己编写的,因为它是由模板创建者提供的.我已经联系了模板创建者并面临绝对糟糕的支持.这是我在这里发帖的主要原因.

                  NOTE: I did not write this code by myself as it was provided by the template creator. I have contacted the template creator and faced an absolutely terrible support. This is the main reason of my post here.

                  推荐答案

                  在进行更多研究和四处询问时,我发现 this 非常有用的答案最终修复了我的本地 XAMPP 配置.所以代码本身没有问题,但我的配置是问题所在.

                  While looking doing more research and asking around I found this extremely useful answer what finally got my local XAMPP configuration fixed. So there was nothing wrong with code itself but my configuration was the issue.

                  重要提示: 尽量按照步骤进行操作,简单的 ; 缺失会对最终结果产生很大影响.因此,请仔细检查每一步是否有问题.

                  IMPORTANT: try to follow the steps as close as possible, simple ; missing can do the big difference in the final result. So double check every step if something seems to be broken.

                  还发现另一个非常有见地和有趣的阅读 发布.

                  Also found one other very insightful and interesting to read post.

                  这篇关于PHP 联系表单的配置问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 XAMPP for Mac Lion 10.8 上安装 Php-intl 下一篇:如何在 php 中启用 sqlite3 的 PDO 驱动程序?

                  相关文章

                  <legend id='yTGHk'><style id='yTGHk'><dir id='yTGHk'><q id='yTGHk'></q></dir></style></legend>
                2. <small id='yTGHk'></small><noframes id='yTGHk'>

                3. <i id='yTGHk'><tr id='yTGHk'><dt id='yTGHk'><q id='yTGHk'><span id='yTGHk'><b id='yTGHk'><form id='yTGHk'><ins id='yTGHk'></ins><ul id='yTGHk'></ul><sub id='yTGHk'></sub></form><legend id='yTGHk'></legend><bdo id='yTGHk'><pre id='yTGHk'><center id='yTGHk'></center></pre></bdo></b><th id='yTGHk'></th></span></q></dt></tr></i><div id='yTGHk'><tfoot id='yTGHk'></tfoot><dl id='yTGHk'><fieldset id='yTGHk'></fieldset></dl></div>

                    <tfoot id='yTGHk'></tfoot>
                      <bdo id='yTGHk'></bdo><ul id='yTGHk'></ul>