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.