在PHP上创建联系人表单时不允许使用405方法

时间:2018-04-04 13:36:08

标签: php html css

当我尝试提交时,我收到405 Method Not Allowed错误。

我从AWS托管,我的域名在GCP上 这是我的index.html文件

 <div class="w3-col m6">
            <form action="#"  action="contact-form.php" method ="post" target="_blank">
                <div class="w3-row-padding contact-form"  style="margin:0 -16px 8px -16px">
                    <div class="w3-half">
                        <input class="w3-input w3-border" type="text" name ="name" placeholder="Name" required name="Name">
                    </div>
                    <div class="w3-half">
                        <input class="w3-input w3-border" type="text" placeholder="Email" name = "email" required name="Email">
                    </div>
                </div>
                <textarea class="w3-input w3-border" type="text" placeholder="Message" name= "message" required name="Message"></textarea>
                <button class="w3-button w3-black w3-section w3-right" type="submit" name="submit">
                    <i class="fa fa-send-o" style="font-size:24px"></i> SEND
                </button>
            </form>
        </div>
    </div>

这是我的联系人 - 来自PHP文件

if(isset($_POST['submit'])){
    $to = "xxx@gmail.com"; // my emails Email address
    $from = $_POST['email']; // sender's Email address
    $name = $_POST['name'];
    $subject = "Form submission";       
    $message = $name . " " . " wrote the following:" . "\n\n" . $_POST['message'];           
    $headers = "From:" . $from;        
    mail($to,$subject,$message,$headers);    
    echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
    header("Location: index.php");

}

0 个答案:

没有答案