简体   繁体   English

有关HTML5主题的联系表单问题

[英]Contact form issues on HTML5 theme

Forgive me, as this probably has an extremely simple solution and I'm just very inexperienced. 请原谅我,因为这可能有一个非常简单的解决方案,而我只是没有经验。

I am using the Massive HTML5 theme and cannot get my contact form to work. 我正在使用Massive HTML5主题,但无法使用我的联系表。 I thought I followed the directions, but still nothing happens when I click SUBMIT. 我以为我遵循了指示,但是当我单击“提交”时仍然没有任何反应。

 <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/> <form method="post" action="contact-us.php" id="form" role="form" class="contact-comments"> <div class="row"> <div class="col-md-6 "> <div class="form-group"> <!-- Name --> <input type="text" name="name" id="name" class=" form-control" placeholder="Name *" maxlength="100" required=""> </div> <div class="form-group"> <!-- Email --> <input type="email" name="email" id="email" class=" form-control" placeholder="Email *" maxlength="100" required=""> </div> <div class="form-group"> <!-- phone --> <input type="text" name="phone" id="phone" class=" form-control" placeholder="Phone" maxlength="100"> </div> </div> <div class="col-md-6 form-group"> <div class="form-group"> <!-- Comment --> <textarea name="text" id="text" class="cmnt-text form-control" placeholder="Comment" maxlength="400"></textarea> </div> <div class="form-group full-width"> <button type="submit" class="btn btn-small btn-dark-solid "> Send Message </button> </div> </div> </div> </form> 

<?php
// Note: filter_var() requires PHP >= 5.2.0
if ( isset($_POST['name']) && isset($_POST['email']) && isset($_POST['subject']) && isset($_POST['comments']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL) ) {

    // detect & prevent header injections
    $mailTest = "/(content-type|bcc:|cc:|to:)/i";
    foreach ( $_POST as $key => $val ) {
        if ( preg_match( $mailTest, $val ) ) {
            exit;
        }
    }

    $headers = 'From: ' . $_POST["name"] . '<' . $_POST["email"] . '>' . "\r\n" .
    'Reply-To: ' . $_POST["email"] . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

    $success = mail( "myemail@mail.com", $_POST['subject'], $_POST['comments'], $headers );
    //  Replace with your email

    if ($success) {
        ?>
        <div style="color:#3c763d;padding:30px;text-align:center">
            <strong>Success!</strong> Message has been sent successfully.
        </div>
        <?php
    }
}

Of course, I changed myemail@mail.com to my address. 当然,我将myemail@mail.com更改为我的地址。

Thanks for the help. 谢谢您的帮助。

mail() function Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise. mail()函数如果已成功接受邮件传递,则返回TRUE,否则返回FALSE。

It is important to note that just because the mail was accepted for delivery, it does NOT mean the mail will actually reach the intended destination. 重要的是要注意,仅仅因为邮件已被接受送达,并不意味着邮件实际上将到达预期的目的地。

please refer Documentation . 请参阅文档

you can also other php library to send mail like phpmailer. 您还可以通过其他php库发送类似phpmailer的邮件。

 if ( isset($_POST['name']) && isset($_POST['email']) && filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) 

从if条件中删除&& isset($ _ POST ['subject'])&& isset($ _ POST ['comments']),因为它们都不是HTML表单中带有名称主题和注释的输入。

If you're on Windows then use XAMPP , if on Mac use MAMP . 如果您使用Windows,则使用XAMPP ;如果使用Mac ,则使用MAMP

PHP contact form will not work if don't have any server side connection. 如果没有任何服务器端连接,则PHP联系人表格将不起作用。 I had the similar problem as you have now. 我遇到了与您现在类似的问题。 For more information please check my post Configuration issue with PHP contact form . 有关更多信息,请检查我的PHP配置表发布问题

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

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