Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Adobe Dreamweaver

Adobe Dreamweaver CS5 with PHP: Validating Input on the Server

In this lesson, with the help of a powerful third-party script library—Zend Framework— David Powers shows you how to create a robust user registration system that validates input on the server.

Note: This excerpt does not include the lesson files. The lesson files are available with purchase of the book.

From the book

What You Will Learn

In this lesson, you will:

  • Install the Zend Framework and set up site-specific code hints
  • Alter a database table to add a unique index and extra columns
  • Validate user input on the server with Zend_Validate
  • Preserve user input and display error messages when input fails validation
  • Create reusable code with Dreamweaver’s Server Behavior Builder
  • Check for duplicate usernames
  • Insert user input into a database with Zend_Db
  • Create a login system with Zend_Auth

Approximate Time

This lesson takes approximately 3 hours to complete.

Lesson Files

Media Files:



Starting Files:




Completed Files:
















Using JavaScript for validation is not enough on its own, because it takes only a few seconds to turn off JavaScript in a browser, rendering your validation script useless. Before inserting user input into a database, you must validate it on the server with a server-side language, such as PHP.

In this lesson, with the help of a powerful third-party script library—Zend Framework— you’ll create a robust user registration system that validates input on the server. This involves writing your own PHP code rather than relying on Dreamweaver to generate it for you. Any inconvenience is more than made up for in greater functionality, and the process is simplified by site-specific code hints.

You’ll also use Dreamweaver’s Server Behavior Builder to speed up the insertion of frequently used PHP code.

Figure 1 The registration form alerts the user to errors before inserting details into the database.

Introducing the Zend Framework

The Zend Framework (ZF) is a huge open source library of PHP scripts. The “minimal” version of ZF 1.10 consists of more than 2,700 files in nearly 500 folders, and is more than 22 MB in size. Of course, size isn’t everything. In fact, you might wonder why you need so many files to do a few basic tasks, such as inserting and updating records in a database, uploading files, and sending emails.

Frameworks provide a wide range of options, many of which you might never use. For example, ZF has 14 components that access different e-commerce services on Most developers never use them, but they’re indispensible if you have an Amazon affiliate account. Instead of writing a script of mind-numbing complexity, you can query the Amazon database with just a few lines of code.

Most tutorials assume you want to use ZF to build a web application using the Model-View-Controller (MVC) design pattern, which divides data handling (the model), output (the view), and conditional logic (the controller) among separate scripts. Unless you have considerable PHP experience, the MVC design pattern can be confusing, so this book takes a different approach, offering a gentler introduction to ZF.

ZF is a loosely coupled framework, which means each part is designed to work with minimal dependency on other parts. You can use just a few components without needing to learn the whole framework. But should you decide later to adopt MVC, your knowledge of key ZF components will speed up the transition.

Here are the main components you’ll be using in the remaining lessons:

  • Zend_Auth to check user credentials
  • Zend_Db to communicate with a database
  • Zend_File to upload files
  • Zend_Loader to load ZF classes automatically
  • Zend_Mail to send emails and attachments
  • Zend_Paginator to page through a long series of database results
  • Zend_Service_ReCaptcha to prevent spam input
  • Zend_Validate to validate user input

The exercises continue using MySQL, but Zend_Db makes the code more flexible. Changing just one or two lines allows you to switch to Microsoft SQL Server, PostgreSQL, or another database system.

ZF has a number of other factors in its favor:

  • Its principal sponsor is Zend Technologies, the company founded and run by PHP core contributors.
  • Leading software companies, including Adobe, Google, and Microsoft, have contributed components or significant features. Adobe contributed Zend_Amf, which acts as a gateway between PHP and the Flash Player, using the binary Action Message Format (AMF).
  • ZF was designed from the outset to use PHP 5 objects. Many frameworks were originally designed for compatibility with PHP 4, which is less efficient.
  • The next major version of ZF is being designed to enhance interoperability with other frameworks, such as Symfony.

Installing the Zend Framework

The CD accompanying this book contains Alternatively, download the most recent version from Choose the Minimal version of ZF, which contains all the files you need. Some download links require you to establish a Zend account. Like ZF, this is free and does not entail any obligations.

To install ZF, simply unzip the file to a suitable location on your hard disk. It’s more efficient to locate it outside the phpcs5 site root, so it’s accessible to all sites in Dreamweaver. Create a folder called php_library at the top level of your C drive on Windows or in your home folder on a Mac, and unzip ZF there.

Two folders, bin and library, are inside the main folder. The framework is in a subfolder of library called Zend. Each component has a corresponding .php file in the Zend folder plus a folder of its own.

There’s no need to open the files, but if you do, you’ll see that each file is extensively commented, which partly explains why the framework is so big. As you gain more experience, you’ll discover a lot of useful information in these comments. Sometimes they help explain features that are not fully documented.

Setting up site-specific code hints for ZF

In Lesson 4, you learned how to create site-specific code hints for WordPress, Drupal, and Joomla! Dreamweaver automatically recognizes the structure of these CMSs. With other frameworks, including ZF, you need to tell Dreamweaver where to find the files and which ones you want to scan to generate code hints. You don’t need the WordPress code hints again in this book, so the following instructions show how to set up a separate structure for ZF hints. This replaces the existing version of dw_php_codehinting.config in the phpcs5 site, but you can easily switch between different sets of code hints by selecting them in the Structure menu of the Site-Specific Code Hints dialog box.

  1. In the Dreamweaver Files panel, select the PHP CS5 site.
  2. Make sure the active file in the Document window is from the current site, or close all files.
  3. Choose Site > Site-Specific Code Hints.
  4. Make sure the Structure menu is set to <New from Blank>.
  5. Click the “Select sub-root folder” icon next to the Sub-root text box, and navigate to the library folder one level above the Zend folder.
  6. Click Select. Because the folder is outside the site root, Dreamweaver displays the following alert.
  7. Just click OK.

  8. Click the plus (+) button above the File(s) area to open the Add File/Folder dialog box.
  9. Click the “Select folder” icon next to the File/Folder text box, and select the Zend folder.
  10. The Recursive checkbox tells Dreamweaver whether to scan all subfolders. If you select the checkbox for the Zend folder, code hints are enabled for the entire framework. Because ZF contains so many files and folders, scanning all of them is not a good idea, so leave the checkbox deselected.
  11. To make the scanning process more efficient, click the plus button above the Extensions area, and type .php in the highlighted section. This tells Dreamweaver to scan only .php files.
  12. Click Add, and repeat steps 7–10 to add the following folders, all of which are subfolders of Zend: Auth, Captcha, Db, File, Loader, Mail, Paginator, and Validate. When setting up each folder, select the Recursive checkbox and add .php to the Extensions list.
  13. You also need to add the Service folder and one of its subfolders, ReCaptcha. The Service folder contains many subfolders, so select the Recursive checkbox only for the ReCaptcha subfolder.

    If you forget to select the Recursive checkbox or add the .php filename extension, you can change the options using the checkbox and button at the bottom of the Site-Specific Code Hints dialog box.

  14. Save the configuration by clicking the Save Structure icon at the top right of the dialog box .
  15. Type Zend in the Name text box (you can use any name except Custom, Drupal, Joomla, or WordPress), and click Save.
  16. Click OK to close the Site-Specific Code Hints dialog box. This inserts a file called dw_php_codehinting.config in the site root. Dreamweaver uses this to scan the ZF folders and create code hints for the selected components.

Peachpit Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Peachpit and its family of brands. I can unsubscribe at any time.


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Peachpit products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information

To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.


Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.


If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information

Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.


This site is not directed to children under the age of 13.


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information

If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at and we will process the deletion of a user's account.


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive:

Sale of Personal Information

Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to

Supplemental Privacy Statement for California Residents

California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure

Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact

Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice

We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020