0

好的,我需要将此联系表突出显示为红色,并在框中说无效!无论我做什么,我都无法让它发挥作用!我无法更改已经存在的 HTML 标签,您可以将其添加到 HTML 但不能删除任何标签,但我希望它与 JavaScript 显示在同一页面上,并且看起来非常好,有人可以编辑我拥有的内容并提供帮助请让我完成这项工作!

哦,我每次测试时都会收到 2 封电子邮件!

这是HTML:

        <!-- Contact -->
        <div class="wrapper wrapper-style4">
            <article id="contact">
                <header>
                    <h2>Want to hire me? Get in touch!</h2>
                    <span>I do quality work and would love to work for you!.</span>
                </header>
                <div>
                    <div class="row">
                        <div class="12u">
                        <div id="errors"></div>
                            <form method='post' action='mailform.php' id='contact-form'>
                                <div>
                                    <div class="row half">
                                        <div class="6u">
                                            <input type="text" name="name" id="name" placeholder="Name" />
                                        </div>
                                        <div class="6u">
                                            <input type="text" name="email" id="email" placeholder="Email" />
                                        </div>
                                    </div>
                                    <div class="row half">
                                        <div class="12u">
                                            <input type="text" name="subject" id="subject" placeholder="Subject" />
                                        </div>
                                    </div>
                                    <div class="row half">
                                        <div class="12u">
                                            <textarea name="message" id="message" placeholder="Message"></textarea>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="12u">
                                            <a href="#" class="button form-button-submit">Send Message</a>
                                            <a href="#" class="button button-alt form-button-reset">Clear Form</a>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
        <!-- Contact -->
        <div class="wrapper wrapper-style4">
            <article id="contact">
                <header>
                    <h2>Want to hire me? Get in touch!</h2>
                    <span>I do quality work and would love to work for you!.</span>
                </header>
                <div>
                    <div class="row">
                        <div class="12u">
                        <div id="errors"></div>
                            <form method='post' action='mailform.php' id='contact-form'>
                                <div>
                                    <div class="row half">
                                        <div class="6u">
                                            <input type="text" name="name" id="name" placeholder="Name" />
                                        </div>
                                        <div class="6u">
                                            <input type="text" name="email" id="email" placeholder="Email" />
                                        </div>
                                    </div>
                                    <div class="row half">
                                        <div class="12u">
                                            <input type="text" name="subject" id="subject" placeholder="Subject" />
                                        </div>
                                    </div>
                                    <div class="row half">
                                        <div class="12u">
                                            <textarea name="message" id="message" placeholder="Message"></textarea>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="12u">
                                            <a href="#" class="button form-button-submit">Send Message</a>
                                            <a href="#" class="button button-alt form-button-reset">Clear Form</a>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>

我需要这里的 JavaScript:

    <script>

    </script>

PHP表单在这里:

    <?php
$to = "bcw1995@gmail.com";
$subject = $_REQUEST['subject'];
$message = $_REQUEST['message'];
$from = $_REQUEST['email'];
$headers = "From:" . $from;
mail($to,$subject,$message,$headers);
if (isset($_REQUEST['email']))
//if "email" is filled out, send email
  {
  //send email
  $email = $_REQUEST['email'] ;
  $subject = $_REQUEST['subject'] ;
  $message = $_REQUEST['message'] ;
  mail($_REQUEST['email'], $subject,
  $message, "From:" . $email);
  }
  header("Location: http://www.thorbis.com/#contact");
?>

有人可以解决这个问题,您将成为救生员!

4

1 回答 1

0

您会收到两封电子邮件:

您的邮件被发送两次,因为您调用了两次 mail() 函数。删除此行mail($to,$subject,$message,$headers);

// 编辑

将第二个电子邮件功能更改为:mail($to, $subject, $message, "From:" . $email); 否则发件人将收到他发送的电子邮件。

验证:

Javascript 表单验证有很多方法和库。我推荐 jQuery + jQuery.Validation 插件 ( http://jqueryvalidation.org/ )。但我也会在 PHP 文件中添加一个验证,因为如果有人禁用了 javascript,他可以发送空电子邮件。

我希望我能帮助你。

于 2013-09-10T13:44:11.553 回答