Form Actions

Question: I have created my form, and validated it. But how do I assign it to a form handler like (CGI,PHP,MYSQL e.t.c)? I will like to also know how to create a confirmation page that enables a visitor to know that he has succefully filled the form: by displaying some or all data entered by a visitor.

Also, how do I create a page that tell a visitor that an error occure in processing of his form if he fails to enter a valid information?
Emmanuel Okaiwele

Answer: The form handler is assigned in the action attribute:

<form action="formhandler.cgi">

The form tag should also have a method attribute specifying whether the form is being used to retrieve data (method="get") or is potentially updating data stored on the server (method="post"). These also result in the data from the form being passed in different ways so as to allow browsers to cache the results from retrieval requests so if you ask for the same thing again it doesn't need to revisit the server and in the case of updates to pass the data using a mechanism that allows for a much larger amount of data to be passed.

The form handler script will need to generate the confirmation page. You can have the script output whatever information from the form that you want into the page (remembering to escape it in a way that ensures that it doesn't get misinterpreted as HTML). This script also controls what error messages get displayed and whether the form is redisplayed to allow the errors to be corrected or not.

Depending on your particular requirements you may be able to use a script someone else has already written or if no such script exists you may need to write your own or have someone write it for you. If you use a script someone else has already written then you use you may need to provide information in hidden fields in the form in order to provide instructions to the script as to how it is to process the form data.


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow