How to use HTML form action attribute with examples

The Form action attribute

The HTML form action attribute specifies the target page where information will be submitted. Generally this is a scripting page that processes the information. For example, a sign-up form that leads to the saveinfo.php target page. The saveinfo.php connects to a database server and saves the sign-up form information to the database and redirects the user to the success page.

Similarly, a contact page’s form action can be “sendemail.php” page which might be a script that not only saves the information to the database but also sends an email to the website’s concerned department.

Example of using form action attribute

The following example shows how to use the form action attribute. Note that, saveinfo.php must be in the same directory where the form is placed (in this case). Or change the path in action attribute accordingly, to point to the right target page.

A few examples of HTML form action

Example of HTML form with input type text

Example of using input button at onclick

Example of HTML with input type file

Input type checkbox with example

Example of image as submit

Also see The forms of HTML | HTML table | HTML div tag | HTML hyperlinks

Was this article helpful?

Related Articles

Leave A Comment?