0

In one of my HTML files, some data is sent to a PHP file using the POST method. See below for the HTML.

<!DOCTYPE html>
<html>
    <head>
        <title>
            Test
        </title>
    </head>

    <body>
        <p>
            Fill in your e-mail address.
        </p>

        <form action="test_db.php" method="post">
            <label>
                E-mail<input type="text" name="email" />
            </label>

            <button>Submit</button>
        </form>
    </body>
</html>

And the PHP file currently only has a very simple task: to display the variable passed to it via the HTML form. See below.

<?php
    // Save input
    $email = $_POST["email"];
    // Display
    var_dump($email);
?> 

However, when I run the code in Visual Studio Code, and when I fill in the form, I get the error "This page isn’t working", with a 405 status code.

So far I have:

  • Added "C:\xampp\php" to my PATH as suggested here.
  • Followed this and this tutorials.
  • Set the php.validate.executablePath in VSCode to "C:\xampp\php".
  • Searched various solutions on the internet.

It seems that the error I am getting is quite easily resolved, but I have hardly any experience in PHP, so all suggestions are welcome.

  • 1
    HTTP 405 means, the request method (POST) isn't allowed on the requested resource. – Honk der Hase Mar 08 '23 at 19:36
  • @HonkderHase thanks, but what does that mean (what is the requested resource)? – Value_Investor Mar 09 '23 at 09:38
  • Not a fix but note that the [](https://html.spec.whatwg.org/dev/embedded-content.html#the-input-element) tag does not use and does not need a closing slash and never has in any HTML specification. – Rob Mar 09 '23 at 09:42

0 Answers0