TOC

The community is working on translating this tutorial into Hebrew, but it seems that no one has started the translation process for this article yet. If you can help us, then please click "More info".

Forms:

Sending the Data

Until now we have not discussed how to actually send the data entered by the user. You can either send it to your email address, to another page, or to your database.

Whichever option you choose, you always have to define how the browser handles the user input. This is defined through the method attribute, which can have one of two values – post or get.

<form action="url-to-formmail-provided-by-your-ISP" method="post">

The get value ensures that the data is to be encoded by the browser into a url and post means that the data is sent to a database or your email. This means, that generally you will use the post value as it is used for form submissions.

The easiest way to handle your data is to send it to your email. All you have to do is add the action attribute to the form element and the method attribute. The action attribute tells the browser what to do with the content of your form and the method attribute tells the browser how to handle it. Here is an example:

<form action="mailto:your@email.com" method="post">
	First name: <input type="text" name="firstname" /> 
	Surname: <input type="text" name="surname" />
	<input type="submit" value="Submit now" />
</form>

If you choose to use this method you need to be aware that the functionality depends on the email-client installed on your users’ computer. This means, that not all users will be able to use your form.

Otherwise you could use the formmail, which I mentioned earlier. When using a formmail, the value of the method attribute should always be post as you are sending the data.


This article has been fully translated into the following languages: Is your preferred language not on the list? Click here to help us translate this article into your language!
adplus-dvertising