PHP联系表单,弹出窗口响应

时间:2014-04-05 19:17:05

标签: php html css3

我在HTML5的模态弹出窗口中有一个简单的联系表单,用CSS3设置了一个简单的PHP文件来处理电子邮件的发送,但我试图让响应错误或确认消息在窗口中发送弹出窗口,它不工作,我一直收到错误,(警告:无法修改标头信息 - 已经发送的标头(输出从/home4/xeopuppy/public_html/GUI/contact.php:5开始) )在/home4/xeopuppy/public_html/GUI/contact.php第21行),但我真的不知道什么时候涉及PHP,任何帮助将不胜感激。

HTML文件

<div class="md-modal md-effect-1" id="modal-6"> <!-- Contact Button Modal -->
    <div class="md-content">
      <h3>Contact Me</h3>
      <div>

      <section class="body">
         <form method="post" action="contact.php">

            <label>Name</label>
            <input name="name" placeholder="Type Here" required>

            <label>Email</label>
            <input name="email" type="email" placeholder="Type Here" required>

            <label>Message</label>
            <textarea name="message" placeholder="Type Here"></textarea>

            <label>*What is 2+2? (Anti-spam)</label>
            <input name="human" placeholder="Type Here">

            <input id="submit" name="submit" type="submit" value="Submit">

         </form>

       </section>
       <button class="md-close">Close me!</button>
     </div>
    </div>
</div> <!-- Contact Button Modal End -->

<div class="md-modal md-effect-1" id="message"> <!-- Contact Message Modal -->
  <div class="md-content">
     <h3>Message</h3>
     <div>
         <?php if(isset($msg)){echo $msg;}?>
         <button class="md-close">Close me!</button>
     </div>
  </div>
</div> <!-- Contact Message Modal End -->

Contact.php文件。

<?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $from = 'From: Kreature-Designs'; 
    $to = 'davidxkirtley@kreature-designs.com'; 
    $subject = 'Hello';
    $human = $_POST['human'];

    $body = "From: $name\n E-Mail: $email\n Message:\n $message";

    if ($_POST['submit']) {
    if ($name != '' && $email != '') {
        if ($human == '4') {                 
            if (mail ($to, $subject, $body, $from)) { 
            $msg="Your message has been sent!";

        } else { 
            $msg="Something went wrong, go back and try again!"; 
        } 
    } else if ($_POST['submit'] && $human != '4') {
        $msg="You answered the anti-spam question incorrectly!";
    }
    } else {
        $msg="You need to fill in all required fields!!";
    }
header("Location:http://www.kreature-designs.com/GUI/gui.html#message"); 
}
?>

0 个答案:

没有答案