|
Web Design ![]() This website demonstrates using wikis as teaching and learning tool. The course instructor is happy to share the teaching materials here with those who find it readable. |
Lecture /
Web FormsA Web Design Lecture by Steven Choy Overview: What is web forms - How forms work - Basic form elements - Error checking - Online form design tips
What are web forms?
How forms work
<fieldset><legend>Contact Us</legend> <form action="FormToEmail.php" method="post"> <label>Name</label><br/> <input type="text" class="text" name="name"/><br/> <label>Email</label><br/> <input type="text" class="text" name="email"/><br/> <label>Address</label><br/> <input type="text" class="text" name="address"/><br/> <label>Message</label><br/> <textarea name="message"></textarea><br/> <input type="submit" value="send" /> </form> </fieldset>
name=Steven+Choy&email=steven@stepwise.hk&address=123+King+Road&message=This+is+a+test+message
$name = $_REQUEST['name'];
$email = $_REQUEST['email'];
$address = $_REQUEST['address'];
$message = $_REQUEST['message'];
Basic form elements
(Source: http://www.phpform.org/)
<form>
First name:
<input type="text" name="firstname" />
<br />
Last name:
<input type="text" name="lastname" />
</form>
<textarea name="comment" rows="60" cols="20"></textarea>
<form>
<input type="radio" name="sex" value="male" /> Male
<br />
<input type="radio" name="sex" value="female" /> Female
</form>
<form>
I have a bike:
<input type="checkbox" name="bike" value="1" />
<br />
I have a car:
<input type="checkbox" name="car" value="1" />
<br />
I have an airplane:
<input type="checkbox" name="airplane" value="1" />
</form>
<select name="fruit">
<option value="apples">Apples</option>
<option value="bananas" selected>Bananas</option>
<option value="cherries">Cherries</option>
</select>
<form name="input" action="html_form_submit.asp" method="get">
Username:
<input type="text" name="user" />
<input type="submit" value="Submit" />
</form>
<input type="hidden" name="Language" value="English">
<input type="hidden" name="comment_post_ID" value="30" />
A hidden field is similar to a text field, but it does not show on the Web page. Therefore the user can't type anything into a hidden field. It is used to submit information that is not entered by the visitor.
In Web form, the LABEL element is used to associated a label with an input element.
The form field labels are important for assessibility of Web forms.
Class discussion: What is the advantage of adding a contact form (vs. giving a contact email) for a website?
Error checking / Input Validation
Advantage: the work of input validation is offloaded from the Web server to the client (users' computer)
Disadvantage: the input validation can be bypassed by users
Advantage: your visitors do not need JavaScript
Disadvantage: it is slower
Many sites use both JavaScript and server-side errer checking, as it is quickly for the majority of visitors with JavaScript, but still works for those who don't have it.
Some online form design tipsForms are the main way people interact with a website. In order for your site to achieve your business goals, it is important your forms are easy to use.
Reading and Resources for you to explore moreThere are a number of resources available that have been created to make it easier for designers, developers, and website owners to quickly and easily create attractive, usable forms without the need to code. In this post we’ll look at some of the best options available.
Free HTML Form Builder - Create Web Form Template Online
Forms aren’t there just to look pretty, they need to work. There are two primary functions a web form can have: to interface with a database or to generate an email. Web Form Factory is an open source service which takes your form and generates the code needed to make it do what it needs to do.
phpFormGenerator is an easy, online tool for creating reliable, efficient, and aesthetically pleasing web forms in a snap. No programming of any sort is required: phpFormGenerator generates the HTML code, the form processor code (PHP), and the field validation code automatically via an easy, point-and-click interface.
FormToEmail is a form processor (form mail) script written in PHP. It comes in a free version and a Pro version. It processes web forms. It sends the contents of web forms by email. It will process any form. It doesn't make forms, it processes them. It comes with HTML code for a basic contact form that you can use on your website. It is very secure and cannot be hijacked by spammers. It is very simple to install, you only need to add your email address to it. Step-by-step instructions written in plain English.
wForms is an open-source, unobtrusive javascript library that adds commonly needed behaviors to traditional web forms without the need for any programming skill.
Thanks for ReadingIf you would rather like to have this lecture note in printed format, please click the print action link in the top right corner. If you find any problem in this lecture note, please feel free to tell Steven via steven [at] findaway.hk. |