A form’s action attribute tells the browser where to submit the form. That destination is written as a URL reference, and a path such as foo.php does not prove that a physical PHP file exists. The web server or application may route that address to code, a controller, a proxy, or another handler.
What a URL is
A URL (Uniform Resource Locator) is an address used to locate a resource or identify where a request should go. A common web URL is:
As an Amazon Associate I earn from qualifying purchases.
https://example.com:443/search?q=html#results
| Part | Example | Purpose |
|---|---|---|
| Scheme | https |
Specifies the access protocol. |
| Authority | example.com:443 |
Identifies the host and, when present, the port. |
| Path | /search |
Identifies a route or resource on the server. |
| Query | ?q=html |
Carries parameters for the server or application. |
| Fragment | #results |
Points to a location within the returned resource. |
These parts are optional in different combinations. For example, mailto:foobar has a scheme but no web host or path in the usual HTTP sense. Web URLs also commonly omit the standard port because the protocol supplies a default.
What the form action attribute does
In this example, foo.php is a relative URL reference:
#1 Best Overall
<form action="foo.php" method="post">
<label>Email <input name="email" type="email"></label>
<button type="submit">Send</button>
</form>
When the user submits the form, the browser resolves foo.php against the document’s URL (or against a document <base> element, if one is present) and sends the form data to the resulting destination. The reference does not mean “open a file named foo.php on my computer.”
How common references resolve
foo.phpis resolved relative to the current document location./foo.phpstarts at the website’s server root.https://example.com/forms/submitis an absolute URL and states the destination directly.
For example, if the page is https://example.com/account/register.html, an action of foo.php normally targets https://example.com/account/foo.php. A leading slash instead targets https://example.com/foo.php. A <base href="..."> can change how relative references are resolved.
Rank #2
Why a URL can look like a filename
The path component is an address in a server’s URL space, not a promise about its storage layout. A server may map /foo.php to a real script, rewrite it to another endpoint, dispatch it through a framework, serve generated content, or reject it. Clean routes such as /checkout can likewise be backed by code rather than a directory or file with that exact name.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
The browser only needs a valid destination and an HTTP response. Whether the server uses a physical file is an implementation detail.
action and method are separate
action supplies the submission destination. method selects the form-submission method, commonly get or post; it is not determined by the filename in action.
| Markup | Typical result |
|---|---|
<form action="/search" method="get"> |
Form values are encoded into the request URL, usually as a query string. |
<form action="/account" method="post"> |
Form values are sent in the request body. |
The appropriate method depends on what the operation does and how the server expects to receive the data. The action and method attributes have distinct roles.
Rank #4
What happens when action is omitted
With no action attribute, submission commonly targets the current page URL. This is useful when one endpoint both renders a form and processes its submission, but it is a design choice rather than a requirement. An explicit action can make the destination clearer and less sensitive to changes in the page URL.
The Tool Desk
Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Understanding the fragment
In https://example.com/search?q=html#results, the fragment is #results. It identifies a location inside the resource, such as an element with a matching id. The fragment is handled by the browser and is not sent to the server in the HTTP request. Server-side code therefore cannot use a fragment as submitted form data.
Absolute and relative URL references
| Reference type | Example | What determines the final destination |
|---|---|---|
| Absolute | https://example.com/submit |
The reference itself supplies the scheme, host, and path. |
| Root-relative | /submit |
The current site’s origin supplies the scheme and host. |
| Document-relative | submit or ../submit |
The current document URL, subject to any <base>, supplies the missing context. |
Diagnosing an unexpected form destination
- Inspect the rendered form and record the exact
actionvalue. - Check the page URL and whether the document contains a
<base>element. - Resolve the reference, paying attention to a leading slash, directory names, and
..segments. - Confirm the form’s
methodseparately; do not infer it from the action path. - Use the browser’s Network panel to see the actual request URL, method, query string, status, and response.
- If the URL looks like a file but fails, check server routing, rewrite rules, deployment paths, and whether the endpoint accepts that method.
The Bottom Line
A form action is a URL reference naming the submission destination. A filename-looking path such as foo.php may map to a real script, but it may just as easily be a routed application endpoint; resolve relative references in the page’s context and treat action and method as separate settings.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




