Search code examples
phpformsxampp

Do I need Xammp for single php file to work?


I'm an absolute beginner when it comes to PHP. I have a standard html/css/js project that I'm editing with VS code and running a development server with the Live Server extension, which is running on localhost:5500.

I'd like to integrate a single .php file into my project which will handle a form submission.

Will I need xampp running on my local machine in order for the .php file to work?

At the moment the form action is sending a post request to my .php file but I get a 405 error from the browser.


Solution

  • Yes, A PHP processor is needed for the PHP code to work. If you have XAMPP installed (which means you have php), you can run

    php -S localhost:5501 (make sure C:/xampp/php is in your PATH environment variable)

    in the root directory of your project, this will start a PHP server and you don't have to move everything to the htdocs folder.