The HTML form is a part of the document that contains controls such as input fields, password fields, checkboxes, radio buttons, menus, etc. The HTML form gives the facility to enter data that is to be sent to the server for processing such as name, email, address, password, etc.
Example:
<!DOCTYPE html>
<html>
<body>
<form action="/sample_page.php">
First name:<br>
<input type="text" name="firstname" value="Your First Name"><br>
Last name:<br>
<input type="text" name="lastname" value="Your Last Name"><br><br>
<input type="submit" value="Submit">
</form>
<p>On clicking the "Submit" button, the form-data will be sent to a page called "/sample_page.php".</p>
The action attribute of the <form> tag specifies where the form data is to be sent to the server after submission of the form. It is used in the <form> element.
<form action="/sample_page.php">
In the example above, the form data is sent to a page on the server called “/sample_page.php”.
If the action of the form is omitted then the action is set to the current page.
The Target Attribute:
The target attribute is used to specify whether the submitted result will open in the current window, a new tab or on a new frame.
The default value of the target attribute is “_self” which means the form will be submitted is the current window.
_self: It will open the linked document in the same frame
_parent: It will open the linked document in the parent frameset
_top: It will open the linked document in the full body of the window
framename: It will open the linked document in the named frame
The Method Attribute:
The method attribute defines the HTTP method used to submit the form.
The values of the method attribute are:
get: In the get method, the submitted data will be visible after the submission of the form.
It is the default value while submitting the form, but it is not secure as it displays the data after submission.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.Ok