Submitting

suggest change

The Action Attribute

The action attribute defines where the form is submitted, which usually is a script that collects the information and works with it. If you leave it blank, the browser submits to the same URL.

<form action="action.php">

The Method Attribute

The method attribute is used to define the HTTP method of the form which is either GET or POST.

<form action="action.php" method="get">
<form action="action.php" method="post">

The GET method is mostly used to get data, for example to receive a post by its ID or name, or to submit a search query. The GET method will append the form data to the URL specified in the action attribute.

www.example.com/action.php?firstname=Mickey&lastname=Mouse

The POST method is used when submitting data to a script. The POST method does not append the form data to the action URL but sends it in the request body.

To submit the data from a control, a name attribute must be specified.

As an example let’s send the value of the field and set its name to lastname:

<input type="text" name="lastname" value="Mouse">

More attributes

<form action="action.php" method="post" target="_blank" accept-charset="UTF-8" 
enctype="application/x-www-form-urlencoded" autocomplete="off" novalidate>

<!-- form elements -->

</form>

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents