Form sends GET instead of POST
One way to solve this is to reinforce your intentions by expliciting formmethod="post"
, like this:
<button type="submit" formmethod="post" formaction="add_user.php">Submit</button>
If like me you gone from Routed url (like in Laravel) to plain PHP, and wonder why the file /user/store/index.php
responds that it receives a GET request using:
<form method="POST" action="/user/store">
<input type="text" id="user_name" name="user_name" />
<button type="submit">Create a new user</button>
</form>
Just check it again... Yes you forgot a trailing slash... so /user/store
will receives only get, while /user/store/
will receive what you form requested.
Edit
I inspected what Laravel does, and it solves this particular issue with this addition in their .htaccess (check the original file).
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]