If you are creating a WWW page, you may wish readers of your page to provide you with information. The HTML language contains a
form construct for this purpose. A form consists of areas of the screen in which the reader of the page can input data. Having typed in this data, the reader presses a Submit button, and the data is emailed back to you.
For pages generated through the Content Management System there are several ways for users of the pages to contact the author. For personal and unofficial pages placed in
public_html directories, there are two options for writing contact forms:
- Write your own form handling code in PHP. This gives the most flexibility, but should only be attempted by people with strong existing PHP experience as it is very easy to introduce a security problem into these forms.
- Use the CIS-supplied form handling software. Firstly, register a form account. This account will have a unique identifying number. Then, create a form on your web page (you can copy and edit the example code below to get started). The contents of that form will then be emailed to you when the form is submitted.
<!-- don't change this line --> <form action='/scripts/usermail.php' method='post'> <!-- change '-1' on the line below to your unique form ID --> <input type='hidden' name='USERFORM' value='-1'> <!-- add the rest of your form fields here --> </form>
CIS used to provide two other pieces of form-handling software. The use of these is now being phased out, and you should switch to this new method as soon as possible. The old software will be removed entirely at a later date.
Online forms tutorials
An example form
Here is an example of a form using the new forms system, that simply takes a short message.
<!-- don't change this line --> <form action='/scripts/usermail.php' method='post'> <!-- change '-1' on the line below to your unique form ID --> <input type='hidden' name='USERFORM' value='-1'> <!-- add the rest of your form fields here --> <table> <tr><th>Your Name</th><td><input name='name' size='30'></td></tr> <tr><th>Your Email</th><td><input name='email' size='30'></td></tr> <tr><th>Your Message</th><td> <textarea name='message' rows='8' cols='60'></textarea></td></tr> </table> <input type='submit' value='Send message'> <!-- end of form --> </form>