1

Running PhpStorm 2016.3.2, Ubuntu 16.04 with PHP7 and LAMP stack installed and tested.

I seem to have an error in PhpStorm (or somewhere else down the line), whereby clicking 'Submit' in an html form will result in a '404 not found' error, even if the form action path is valid.

I built a very simple application to demonstrate this, however it should be noted that this error has occurred every time I use an html form in PhpStorm so far, even example applications that I know have no errors in code.

The code for my form is as follows

 var $form = <<< FORM
 <form action='?' method="post">
 <p>Enter your number </p> 
 <input type="text" name="formInput" 
 maxlength="10"> 
 <input type="submit" name="formSubmit" 
 value="Submit"> 
 </form> 
 FORM;

Once 'Submit' is clicked, the 404 error happens. I have tried multiple permeations of form action such as "" and even a variable set to APP_ROOT_PATH, and then just manually typing out the correct path (even a different php file) also with single and double quotes.

The reason I believe these paths to be valid is that simply by clicking in the address window from the 404 error page and hitting enter (thereby going to the path it was trying to get to) the form loads again fine.

I can't get my head around why this might be, if it was a permissions or path error surely I would not be able to access the path from the browser either?

EDIT: Looking at the source code reveals that the action is what I intended it to be. Even copying the url from there and pasting it into the browser will open the correct form. It is just when clicking 'submit' that the 404 error happens. The correct url is also in the address bar on the 404 page.

EDIT 2 : For note, the '?' action in the above code is irrelevant to the issue as the error occurs no matter what correct link I put there, be it "" or the full path.

  • i think you have problem with form action. action='?', change this to some valid link. – Mubashar Iqbal Mar 15 '17 at 15:45
  • View the rendered source code, and see what the action is, and what the URL is when you click it. If you want the page to submit to itself, leave the action blank. – aynber Mar 15 '17 at 15:46
  • What URL you are using in the browser to see this form? – LazyOne Mar 15 '17 at 15:46
  • could it be, that you have a `header('Location: xy.php')` somewhere in your target php? – Jeff Mar 15 '17 at 15:49
  • 1
    As I said, leaving the form action blank or to a valid link does not resolve the problem, the source code says the action is "" (if I leave it blank) and the url when I click it is the correct one just with a 404 error : see the edit to the original post – ASliceOfBread Mar 15 '17 at 16:13
  • I do not want to sound rude .. but **what is the FULL URL** that you see in address bar when it does not work (even if it's the same when it works) -- I want to see URL (domain name/port number parts in particular). – LazyOne Mar 15 '17 at 16:28
  • Right no the most obvious thing that comes to my mind is -- you are using PhpStorm's own built-in simple web server that at the moment has issues with handling POST data. Solution -- use proper webserver (your Apache) to serve the web pages. http://stackoverflow.com/a/37506720/783119 or http://stackoverflow.com/a/34787827/783119 for example – LazyOne Mar 15 '17 at 16:36
  • dw it's not rude, and I think you are right with the second comment, I set it up with apache and it seems to be working for now, at least for the test application - think I need to tweak it a bit as it's still not working fully but I think that is another problem entirely haha, thanks for the help – ASliceOfBread Mar 15 '17 at 17:13

0 Answers0