Form action="?"

I need help in understanding what this does; specifically the “?”. I’m searching the internet for an explanation, but it doesn’t seem to be documented anywhere. I can find information on a blank form action (form action = “”), and on form action = a url or php file, but not “?”.

Thank you for you help,

Hi my4skcg, welcome to Sitepoint :).

Whatever is inside the quotes is what URL the browser will go to upon submit (your ? example would make it go to The ? at the end of that URL is just what’ll get added on (I assumed in my example that the URL gone to is and when you click submit, it’ll just add on ?, if that makes sense) I’m wondering where you even saw this though?

Normally people send the information to a PHP page (or some other language) for work. Depends on what the form is.

I saw this in a Sitepoint book, Build Your Own Database Driven Web Site Using PHP & MySQL by Kevin Yank. I went back in the book and found where it is first used and the explanation. It’s on page 132 in the book; “…the URL used to display the form in the example will feature a query string, and setting the action to ? strips that query string off the URL.”

I was further into the book and coding the examples, studying the code to make sure I understood it all and did not remember reading this.

Thanks for you help! And for the welcome to Sitepoint! Great books, great prices on books, and a great website!

To put it clearly, just saying ? means sending no getdata to whatever the default page is at the current directory…


is functionally identical to saying:


basically if defaultpage was a variable…


where defaultpage could be any one of:

or whatever else the server it’s running on is set up to check as the default page for /

In Apache the list of files to be called as the index is set via the directoryIndex variable, which you can change or customize with a .htaccess file… and these days typically starts out set to this:

DirectoryIndex index.html index.htm default.htm index.php index.php3 index.phtml index.php5 index.shtml

works like font-family does in CSS… if the first one is found, it’s used, if not try the next one and lather-rinse repeat until one is found.

No. If the current page is “” then resolving “?” against it will result in “” and not “”.