Action normally specifies the file/page that the form is submitted to (using the method described in the method paramater (post, get etc.))

An action of # indicates that the form stays on the same page, simply suffixing the url with a #. Similar use occurs in anchors. <a href=#">Link</a> for example, will stay on the same page.

Thus, the form is submitted to the same page, which then processes the data etc.

Answer from MEURSAULT on Stack Overflow
๐ŸŒ
W3Schools
w3schools.com โ€บ tags โ€บ att_form_method.asp
HTML form method Attribute
<form action="/action_page.php" method="post"> <label for="fname">First name:</label> <input type="text" id="fname" name="fname"><br><br> <label for="lname">Last name:</label> <input type="text" id="lname" name="lname"><br><br> <input type="submit" value="Submit"> </form> Try it Yourself ยป
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Learn_web_development โ€บ Extensions โ€บ Forms โ€บ Sending_and_retrieving_form_data
Sending form data - Learn web development | MDN
The server then responds, generally handling the data and loading the URL defined by the action attribute, causing a new page load (or a refresh of the existing page, if the action points to the same page). How the data is sent depends on the method attribute. The method attribute defines how data is sent. The HTTP protocol provides several ways to perform a request; HTML form data can be transmitted via a number of different methods, the most common being the GET method and the POST method
Discussions

what do <form action="#"> and <form method="post" action ...
I'm reading a book on html development (which I'm fairly new at) and despite the fact that the book just had its 1st publishing one month ago (Nov. 2011), the author is an experienced coder and maybe using # for the action in a form is old school? More on stackoverflow.com
๐ŸŒ stackoverflow.com
How to submit data from HTML form? - WordPress Development Stack Exchange
If you really want your own custom HTML/CSS for the form, convert it to a custom plugin. ... I agree with other answers that most of the time it is better to use a plugin to handle form submissions. However, there are exceptions to this rule. If you find yourself in a situation where you need to handle the form submissions yourself, you can submit data to admin-post.php. Here is how to set that up: First set up your form. More on wordpress.stackexchange.com
๐ŸŒ wordpress.stackexchange.com
August 7, 2018
is this <form action = "index.html" method = "post"> addressing action
Katie O'Connell is having issues with: please provide example if I am wrong More on teamtreehouse.com
๐ŸŒ teamtreehouse.com
1
June 27, 2018
Different ways to submit a form. Which is best for my application?
You should always use either a button or a submit input inside of the form element, regardless of your method of form submission. You've also misunderstood the form action attribute - the action, if used, refers to the URL to which the browser should send a request to on form submission. If you have your own back end application and you want the simplest possible form submission method, you should just use an action and method attribute method on your form element, put a button or submit input inside it, and then when someone submits the form the browser will automatically navigate to the URL that you put as the form action using the HTTP method that you specified, and you can handle that request on your back end as you choose. In the context where you don't have your own back end that handles that kind of form submission, or you want to do something a bit fancier than just navigating the user to another page, you instead need to use JS and listen for the 'submit' event on the form element. If you're using Firebase as your datastore directly from your client-side application then it sounds like that's what you'll need to do. If you're new to working with forms I highly recommend this guide from MDN - the sections on 'sending form data' and 'sending forms through Javascript' are especially relevant. More on reddit.com
๐ŸŒ r/learnjavascript
2
3
November 14, 2021
๐ŸŒ
Programiz
programiz.com โ€บ html โ€บ form-action
HTML Form Action: POST and GET (With Examples)
HTTP methods declare what action ... send user data: GET method - used to request data from a specified resource ยท POST method - used to send data to a server to update a resource...
๐ŸŒ
W3Schools
w3schools.com โ€บ tags โ€บ att_form_action.asp
HTML form action Attribute
The action attribute specifies where to send the form-data when a form is submitted. ... If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: sales@w3schools.com ยท If you want to report ...
๐ŸŒ
Scribd
scribd.com โ€บ document โ€บ 737027105 โ€บ HTML-Form-Action-POST-and-GET-With-Examples
HTML Form Action - POST and GET (With Examples)
JavaScript is disabled in your browser ยท Please enable JavaScript to proceed ยท A required part of this site couldnโ€™t load. This may be due to a browser extension, network issues, or browser settings. Please check your connection, disable any ad blockers, or try using a different browser
Find elsewhere
๐ŸŒ
Formspree
formspree.io โ€บ blog โ€บ html-form-action
A Mini Guide to HTML Form Action | Formspree
February 27, 2025 - In this article, you will discover how the HTML form action attribute works and how to use it effectively to control form submissions, send data to the right destination, and improve user interactions. You will learn best practices for setting up action URLs, handling GET and POST requests, and ensuring seamless form processing on your website.
๐ŸŒ
Career Karma
careerkarma.com โ€บ blog โ€บ html โ€บ html form action attribute: a how-to guide
HTML Form action Attribute: A How-To Guide | Career Karma
December 29, 2020 - The action attribute is used to specify where we want to send the form data when the form is submitted. So the value of the action is the page that will process the form. The HTML form action attribute states the URL that will process the contents ...
๐ŸŒ
SoftUni
softuni.org โ€บ home โ€บ news โ€บ dev concepts โ€บ handling an html form โ€“ get and post methods, and data encoding [dev concepts #38]
Handling an HTML Form โ€“ GET and POST Methods, and Data Encoding [Dev Concepts #38] - SoftUni Global
June 30, 2022 - You add an action attribute to the form to define where the submitted data goes. In the example above the submitted information will be handled by the script of the home.html document.
Top answer
1 of 4
4

I agree with other answers that most of the time it is better to use a plugin to handle form submissions. However, there are exceptions to this rule.

If you find yourself in a situation where you need to handle the form submissions yourself, you can submit data to admin-post.php. Here is how to set that up:

First set up your form.

<!-- Submit the form to admin-post.php -->
<form action="<?php echo esc_url( admin_url('admin-post.php') ); ?>" method="POST">

    <!-- Your form fields go here -->

    <!-- Add a hidden form field with the name "action" and a unique value that you can use to handle the form submission  -->
    <input type="hidden" name="action" value="my_simple_form">

</form>

Now you will set up an action in your functions.php file. You will use the value that you used in your hidden action field in the form.

function my_handle_form_submit() {

    // This is where you will control your form after it is submitted, you have access to $_POST here.

}

// Use your hidden "action" field value when adding the actions
add_action( 'admin_post_nopriv_my_simple_form', 'my_handle_form_submit' );
add_action( 'admin_post_my_simple_form', 'my_handle_form_submit' );

Here is a link to more information from the codex - https://codex.wordpress.org/Plugin_API/Action_Reference/admin_post_(action)

2 of 4
2

Best to put this kind of functionality in a plugin. Not cram it into the theme. You can see an example of a simple contact form plugin for wordpress here: https://www.sitepoint.com/build-your-own-wordpress-contact-form-plugin-in-5-minutes/

Tips:

  • Execute your code on the right moment, find the hook which suits you (ea. the init hook).
  • use wp_mail() in wordpress, not the standard php mail() function

As @WebElaine mentioned above: when you create a plugin for it you won't lose your functionality when switching themes. Also the functionality will be easy to transfer between sites if needed, and you can turn it on/off with the click of a button. If the functionality is only specific for this website, it's still a good idea no to include it in the (child theme's) functions.php. Only "theme" specific functionality (widgets, including specific styling/js files /etc) should be placed there. ea. You wouldn't include the contact form 7 code in your child theme

๐ŸŒ
FormSubmit
formsubmit.co
FormSubmit | Easy to use form backend - form endpoints for your HTML forms
<form action="https://formsubmit.co/[email protected]" method="POST" /> Include a ยท name attribute in all form elements (i.e. <input>, <select>, and <textarea>) to receive the submission data. <input type="email" name="email"> Submit the form once. This first-time-use will trigger an email requesting confirmation. You can play with our interactive playground. The HTML on the left is interactive, you can change the elements are included and the form to the right will be updated immediately.
๐ŸŒ
MDN Web Docs
developer.mozilla.org โ€บ en-US โ€บ docs โ€บ Web โ€บ HTML โ€บ Reference โ€บ Elements โ€บ form
<form>: The Form element - HTML | MDN
The <form> HTML element represents a document section containing interactive controls for submitting information. <form action="" method="get" class="form-example"> <div class="form-example"> <label for="name">Enter your name: </label> <input type="text" name="name" id="name" required /> </div> ...
๐ŸŒ
Medium
medium.com โ€บ @kathrynlael โ€บ html-forms-post-method-and-search-e2d4ff92abbe
HTML Forms Post Method and Search | by Kathryn Clark | Medium
May 9, 2020 - POST request is to create a new instance of your class (this will make more sense later on).The GET request is essentially retrieving a webpage, which will be used later in my Search form.
๐ŸŒ
W3Schools
w3schools.com โ€บ tags โ€บ tag_form.asp
HTML form tag
The <form> tag also supports the Event Attributes in HTML. ... <form action="/action_page.php" method="get"> <input type="checkbox" name="vehicle1" value="Bike"> <label for="vehicle1"> I have a bike</label><br> <input type="checkbox" name="vehicle2" value="Car"> <label for="vehicle2"> I have a car</label><br> <input type="checkbox" name="vehicle3" value="Boat" checked> <label for="vehicle3"> I have a boat</label><br><br> <input type="submit" value="Submit"> </form> Try it Yourself ยป
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ html โ€บ html-form-method-attribute
HTML <form> method Attribute - GeeksforGeeks
July 12, 2025 - This method sends the form-data as an HTTP post-transaction. ... <!DOCTYPE html> <html> <head> <title> HTML form method Attribute </title> </head> <body style="text-align:center;"> <h1 style="color:green;">GeeksforGeeks</h1> <h3>HTML <form> ...
๐ŸŒ
Quora
quora.com โ€บ What-does-form-action-some_url-method-POST-really-mean
What does <form action="some_url" method = POST> really mean?
Consider the following form. ... In this case the action attribute tells the browser which page on the server is to process the ID you enter. The method=get attribute says your entry will be passed openly in the URL. So if I entered โ€œSteveโ€ the action URL would be ... The process.php page can do whatever it needs to with my entry and display its own HTML on the userโ€™s browser. ... RelatedHow does a browser know which HTTP method like GET, POST, etc.
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ library โ€บ http-basics โ€บ using-forms-for-post-requests
Using Forms for POST Requests (How To) | HTTP Basics | Treehouse
Specifically, there are two changes: An input element with the type "file" is added, and ยท The encoding type of the form element must be set to "multipart/form-data" ... <form method="post" action="/update_profile" ...
Published ย  March 18, 2016
๐ŸŒ
HTML.com
html.com โ€บ attributes โ€บ form-method
Attribute for METHOD = GET | POST
November 3, 2019 - <form action="fileupload.php" method="post" enctype="multipart/form-data"> <p>Please select the file you would like to upload.
๐ŸŒ
React
react.dev โ€บ reference โ€บ react-dom โ€บ components โ€บ form
<form> โ€“ React
When a function is passed to action or formAction the HTTP method will be POST regardless of value of the method prop. Pass a function to the action prop of form to run the function when the form is submitted. formData will be passed to the ...