MethodNotAllowedError while using a POST method in PHP
Hi everyone!
I'm trying to get myself into web development and i'm pretty new to this so i apologize in advance for any stupid mistake haha.
I'm practicing how to create forms using PHP and i keep getting an error when i use the POST method when submitting information. Here is my first PHP file (form.php) that has the HTML content:
<html>
<body>
<form method="post" action="form_submission.php">
<p>Name: <input name="name" type="text" /> </p>
<p>Size: <select name="size">
<option value="small">Small</option>
<option value="medium">Medium</option>
<option value ="large">Large</option>
</select></p>
<p>Sex: <input type="radio" name="sex" value="female"/> Female
<input type="radio" name="sex" value="male" /> Male</p>
<input type="submit" name="submit" value="Submit!" />
</form>
</body>
</html>
and here is the code for the form_submission.php file:
<?PHP
if(isset($_POST['submit'])){
$name = $_POST['name'];
$size = $_POST['size'];
$sex = $_POST['sex'];
echo "<p>Name: $name <br> Size: $size <br> Sex: $sex </p>";
}
?>
**SIDENOTE: i have another problem with the echo statement in live view and i don't think it's processing properly; it outputs the last five characters ";}?> at the end and it doesn't register the " as the end of the echo.
When i run the form.php and fill it out i get:
{"code":"MethodNotAllowedError","message":"POST is not allowed"}
Your help is greatly appreciated and any pointers are welcomed
