Home arrow Graphic Design arrow Page 12 - Using HTML Quickform for Form Processing

Using HTML Quickform for Form Processing

With HTML_QuickForm version 3.1, you can have a consistent look across all your forms and a simplified file upload. This chapter starts with the basics then shows you how to process submitted form data with HTML_QuickForm. (From the book, Essential PHP Tools: Modules, Extensions, and Accelerators, by David Sklar, Apress, 2004, ISBN: 159059280.)

Author Info:
By: Apress Publishing
Rating: 5 stars5 stars5 stars5 stars5 stars / 193
September 01, 2004
  1. · Using HTML Quickform for Form Processing
  2. · Steps for the Example
  3. · Individual Elements
  4. · Text, Password, Textarea
  5. · Hidden, Select
  6. · Checkbox, Radio
  7. · Submit, Reset, Button, Image
  8. · File, advcheckbox, Static
  9. · Header, Link, HTML
  10. · Element Groups
  11. · Processing Submitted Data
  12. · Without a Callback Function
  13. · Setting Validation Rules

print this article

Using HTML Quickform for Form Processing - Without a Callback Function
(Page 12 of 13 )

If you donít want to use the process() method and a callback function, you can access submitted form data directly with the getSubmitValues() method. It returns an array of submitted form data. The keys in the array are the names of the form elements, and the values in the array are the corresponding values of each form element. Once you retrieve the array of submitted form data with getSubmitValues(), you can process the information from the form. The following is the simple e-mail message sending example using getSubmitValues() instead of process():

$form = new HTML_QuickForm('send_email');
$form->addElement('text','subject','Subject: ','size="30" maxlength="128"');
$form->addElement('textarea','body','Message Body: ','rows="10" cols="30"');
$form->addElement('submit','send','Send Message'); $data = $form->getSubmitValues();
if ($data['send']) {
print "Your message has been sent.";
} else {

After adding appropriate elements to the form, the program puts any submitted form data into $data by using getSubmitValues(). The submit button in the form is named send, so if that element of data has a value, the program assumes the form has been submitted. It uses the mail() function to send an e-mail message. If $data['send'] is false, then the program displays the form instead.

The getSubmitValues() method of an HTML_QuickForm object only returns data submitted via the method (GET or POST) that the object uses. Variables in the query string arenít included in what getSubmitValues() returns for a POST form. Similarly, variables in POST data arenít included in what getSubmitValues() returns for a GET form. Also, the array getSubmitValues() returns doesnít include any information on uploaded files.

This chapter is from Essential PHP Tools: Modules, Extensions, and Accelerators, by David Sklar, (Apress, 2004, ISBN: 1590592808). Check it out at your favorite bookstore today.

Buy this book now.

blog comments powered by Disqus

- Customizing Wordpress Favicons and Gravatars
- Building Corner Effects with Transparent Bac...
- 3D Graphics Technology: VRML Part I - Introd...
- Creating Visual Effects
- Web Page Design Overview
- Creating Artistic Photographs
- Working with Tools in Paint Shop Pro 8
- Using HTML Quickform for Form Processing
- Introduction to Adobe FrameMaker
- WebLogic Workshop, WebLogic Platform, and th...
- Planning the Site
- Working with Web Services
- WebLogic Workshop Application Development Ba...
- Scanning Images for Web Use
- Web Graphics Overview

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials