Hi
I am new to PHP and I am trying to learn how to post from input on html (jQuery or JavaScript) via a php file, but I always get a 405 error - not allowed. I am not sure on how to overcome the error. I have looked online and cannot find a solution.
I am working on a linux machine (ubuntu) and I have in installed xampp. This is the link to my files on github -GitHub - Temceo/php_test
Any guidance on resolving this issue will be much appreciated. Thank you.
Have you confirmed that php works at all, using a phpinfo(); statement in a .php script file that you request through a URL on the web server, such as http://localhost/some_file.php
Where exactly are you seeing the 405 error and at what point in the process?
I am seeing the 405 error in the browser inspect section (under console and network) on the html page.
Regarding the php page, I have confirmed that it works. I have connected to an external api (openweather) and I am successfully retrieving data from the external api to the php page.
I am only encountering the 405 error whenever I collect input from the html page (using jquery/JavaScript) and try to post it to the php page.
What URL are you entering in the browser for the html page? It should be something like http://localhost/index.html or if the web server is setup with a default document for index.html, just using http://localhost will work.
Could you post a screen-shot of what you are seeing in the browser’s developer tools?
Hi
I have worked out the issue. I am using vs code live server which does not support posting to php. I don’t encounter this issue when I use the built in php web server.