0

我正在尝试使用 HTML 和 PHP 编写联系表单,当我测试代码时它工作正常input type="submit" name="submit" value="Submit"

但是在使用 div & button class:"" 时,它对我不起作用。

有人能帮我吗?

我的 PHP 代码

<? php 

       if(isset($_POST['submit']))

{

        $to = "example@gmail.com";

        $from = $_POST['email'];

      $name = $_POST['name'];

      $email = $_POST['email'];

      $phone =$_POST['phone'];  

      $subject = "Enquiry From".$name;

      $subject2 = "Copy of your Enquiry";

      $message = $name . " " . "wrote the following:" . "\n\n" . $_POST['message'] ."Contact Details:" . "\n\n" .$_POST['email'] . $_POST['phone'];

    $message2 = "Here is a copy of your message " . $name . "\n\n" . $_POST['message'];

    $headers = "From:" . $from;

    $headers2 = "From:" . $to;

    mail($to,$subject,$message,$headers);

    mail($from,$subject2,$message2,$headers2); 

echo "Mail Sent. Thank you " . $first_name . ", we will contact you shortly.";

}
?>

============================

HTML 表单代码

<div class="container-contact100">

    <div class="wrap-contact100">
        <form class="contact100-form validate-form" action="mail.php" method="post">
            <span class="contact100-form-title">
                Feel free to reach us
            </span>

            <div class="wrap-input100 validate-input" data-validate="Please enter your name">
                <input class="input100" type="text" name="name" placeholder="Full Name">
                <span class="focus-input100"></span>
            </div>

            <div class="wrap-input100 validate-input" data-validate = "Please enter your email: e@a.x">
                <input class="input100" type="text" name="email" placeholder="E-mail">
                <span class="focus-input100"></span>
            </div>

            <div class="wrap-input100 validate-input" data-validate = "Please enter your phone">
                <input class="input100" type="number" name="phone" placeholder="Phone">
                <span class="focus-input100"></span>
            </div>
            <div class="wrap-input100 validate-input" data-validate = "Please enter your Subject">
                <input class="input100" type="text" name="subject" placeholder="Subject">
                <span class="focus-input100"></span>
            </div>
            <div class="wrap-input100 validate-input" data-validate = "Please enter your message">
                <textarea class="input100" name="message" placeholder="Your Message"></textarea>
                <span class="focus-input100"></span>
            </div>

            <div class="container-contact100-form-btn">
                <button type="submit" class="contact100-form-btn" type="submit">
                    <span>
                        <i class="fa fa-paper-plane-o m-r-6" aria-hidden="true"></i>
                        Send
                    </span>
                </button>
            </div>
        </form>
    </div>
</div>
<div id="dropDownSelect1"></div>
4

1 回答 1

0

利用

if(isset($_POST['email']))

为什么?您没有任何名称为 submit 的元素。你重复 type=“submit” 两次

于 2018-02-12T23:24:41.473 回答