HTTP Error 405

I’m building a Contact Us Form using this website (https://1stwebdesigner.com/php-contact-form-html/) and I’m running into a problem. Here’s my HTML and PHP code.

<body>
    <form action="mail.php" method="POST">
        <p>Name</p>
        <input type="text" name="name">
        <p>Email</p>
        <input type="text" name="email">
        <p>Message</p>
        <textarea name="message" rows="6" cols="25"></textarea><br>
        <input type="submit" value="Send"><input type="reset" value="Clear">
    </form>
</body>

<?php
    $name = $_POST['name'];
    $email = $_POST['email'];
    $message = $_POST['message'];
    $formcontent="From: $name \n Message: $message";
    $recipient = "youremail@here.com";
    $subject = "Contact Form";
    $mailheader = "From: $email \r\n";
    mail($recipient, $subject, $formcontent, $mailheader) or die("Error!");
    echo "Thank You!";
?>

*I changed the recipient value to my actual email

I tried running this in VSCode via. the Live Server Extension, but I got this error message.

image

image

Where can I go from here? All help is greatly appreciated.

Edit: After some more research, I’ve realized that Live Server doesn’t support PHP. So I guess the question now is do I have to get a hosting platform?

I think so you need a PHP server like wamp, xampp or laragon for the php script works successfully check what is the exactly error that do you have in your network tab of your devTools

1 Like

Thanks for the help! I’ll download xampp and go from there.