Issue with contact form (html and php): 405 not al

2019-08-16 03:31发布

I'm trying to make a very basic contact form using HTML and PHP. For some reason, however, when I click the "submit" button I get the error "405 Not Allowed". Why? How could I fix this? (I'm hosting my website on GitHub)

my HTML:

<!DOCTYPE html>
<html>


<head>
    <title></title>
</head>
<body>

    <form action="send_form_email.php" method="POST">
            <input type="text" name="name" placeholder="Full Name">
            <input type="text" name="mail" placeholder="Your e-mail">
            <input type="text" name="subject" placeholder="Subject">
            <textarea name="message" placeholder="Message"></textarea>
            <button type="submit" name="submit">Send e-mail</button>
    </form>

</body>


</html>

my PHP:

<?php

if (isset($_POST['submit'])) {
$name = $_POST['name'];
$subject = $_POST['subject'];
$mailFrom = $_POST['mail'];
$message = $_POST['message'];


$mailTo = "example@gmail.com";
$headers = "From: ".$mailFrom;
$txt = "You have received an e-mail from ".$name.".\n\n".$message;

mail($mailTo, $subject, $txt, $headers);
header("Location: index.php?mailsend");
}

(PS. I wrote "example@gmail.com" just because I wanted to keep my personal e-mail private on here.

PPS. I have been trying to make a very simple contact form (you write your name mail and message and the owner of the website receives it in the inbox) but none of my (desperate) attempts seems to work. Can anyone help me out?)

0条回答
登录 后发表回答