Quick Reach
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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
<!DOCTYPE html>
<html>
<head>
<title>HTML Forms</title>
<style>
.submitstyle{
font-size:16px;
color:red;
border: 1px solid green;
}
</style>
</head>
<body>
<form action=“saveinfo.php” method=“post”>
Name: <input type=“text”> <br />
Email:<input type=“text”> <br />
<input type=“submit” value=“Save Info”>
</form>
</body>
</html>
|
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
Also see The forms of HTML | HTML table | HTML div tag | HTML hyperlinks
Leave A Comment?