doujia4619 2016-08-25 04:49 采纳率: 0%
浏览 44

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

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. 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"] . '>' . "
" .
    'Reply-To: ' . $_POST["email"] . "
" .
    '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.

Thanks for the help.

</div>
  • 写回答

3条回答 默认 最新

  • duancai7568 2016-08-25 05:00
    关注

    mail() function Returns TRUE if the mail was successfully accepted for delivery, FALSE otherwise.

    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.

    评论

报告相同问题?

悬赏问题

  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 AT89C51控制8位八段数码管显示时钟。
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 下图接收小电路,谁知道原理
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测
  • ¥15 ETLCloud 处理json多层级问题