Adobe Dreamweaver CS5 with PHP: Validating Input on the Server and max tutorial
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:
styles/users.css
styles/users_wider.css
Starting Files:
lesson07/start/add_user.php
lesson07/start/login.php
lesson07/start/members_only.php
Completed Files:
lesson07/completed/add_user.php
lesson07/completed/add_user01.php
lesson07/completed/add_user02.php
lesson07/completed/add_user03.php
lesson07/completed/login.php
lesson07/completed/members_only.php
lesson07/completed/scripts/library.php
lesson07/completed/scripts/library_magic_quotes.php
lesson07/completed/scripts/restrict_access.php
lesson07/completed/scripts/user_authentication.php
lesson07/completed/scripts/user_authentication01.php
lesson07/completed/scripts/user_registration.php
lesson07/completed/scripts/user_registration01.php
lesson07/completed/scripts/user_registration02.php
lesson07/completed/scripts/user_registration03.php
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 Amazon.com. 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.
TIP
ZF is an object-oriented framework. If you're not familiar with PHP objects, now is a good time to review "Using Objects and Resources" in Lesson 3.
Installing the Zend Framework
The CD accompanying this book contains ZendFramework-1.10.6-minimal.zip. 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.

Figure 2
TIP
The ZF documentation at max tutorial is extensive and contains many examples. Unfortunately, much of it is written on the assumption that you are using the MVC design pattern. It also expects you to have a solid understanding of PHP. However, considerable efforts have been made to improve it.
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.
TIP
You can also follow these steps in the final section of my Adobe TV video about PHP code hints at max tutorial.
- In the Dreamweaver Files panel, select the PHP CS5 site.
- Make sure the active file in the Document window is from the current site, or close all files.
- Choose Site > Site-Specific Code Hints.
- Make sure the Structure menu is set to <New from Blank>.
- 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.
NOTE
The sub-root folder must be at least one level higher than any files or folders that you want to scan.
Click Select. Because the folder is outside the site root, Dreamweaver displays the following alert.
Figure 3
Just click OK.
Click the plus (+) button above the File(s) area to open the Add File/Folder dialog box.
Figure 4
Click the "Select folder" icon next to the File/Folder text box, and select the Zend folder. 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. To make the scanning process more efficient, click the plus button above the Extensions area, and type .max tutorial in the highlighted section. This tells Dreamweaver to scan only .php files.
Figure 5
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.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.

Figure 6
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.
Save the configuration by clicking the Save Structure icon at the top right of the dialog box . Type Zend in the Name text box (you can use any name except Custom, Drupal, Joomla, or WordPress), and click Save. 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.TIP
The folders are scanned in reverse alphabetical order each time you launch Dreamweaver. This process shouldn't slow down the program, but if you select the whole framework, it can take several minutes before all code hints are ready for use.
Questions and Answers
This excerpt from Adobe After Effects CS5 Classroom in a Book shows you how to add lights, effects, reflections, and other elements to a composition. In doing so, you'll learn how to use additional 3D features available in Adobe After Effects.
This excerpt from Adobe After Effects CS5 Classroom in a Book shows you how to use the new Roto Brush tool in After Effects CS5, which is much faster than conventional rotoscoping, and for movies with complex backgrounds, much easier than keying.
This excerpt from Adobe After Effects CS5 Classroom in a Book shows you how to create a mask using the Pen tool, edit a mask, feather a mask edge, create a vignette, and more.
Continuing their series on the design and creation of WorkflowLab, Aaron Pedersen, James Polanco, and Doug Winnie, the authors of Adobe Flash Platform from Start to Finish: Working Collaboratively Using Adobe Creative Suite 5, discuss the final UI design process used to create the design comps and assets required to complete the project.
The best part of drawing on a computer is that you rarely have to start over. Whether you've changed your mind about an angle or you drew a bunch of repeated objects too small (oops), Illustrator makes modifying your artwork very easy. Mordy Golding discusses how to use Illustrator's transform capabilities to manipulate any number of objects onscreen.
By using CSS3 style sheets, you can apply some pretty cool visual effects to content in your web pages. David Karlins, author of Adobe Creative Suite 5 Web Premium How-Tos: Essential Techniques, shows how to work with a few of these effects in Dreamweaver CS5.
Painting for sale and Art reproduction are in demand from different occasion period. Besides that there is a special time and appeal ,to network with all of them. There is no preplanned to obtain them:- On line or form a shop . You have to be keep in touch with some pointers that can directly lead you there and must provide the relevant material for which you are searching.
"Leda And The Swan", by Leonardo da Vinci, is one of history's great art losses. From the surviving copies we can see its beauty, the masterly composition, and the complex emblematic symbolism. Leonardo went beyond the sexual act portrayed until then about this mythic story. The great popularity of this subject in the sixteenth century was due to the fact that it was then more acceptable to depict a woman having an act of copulation with an animal than with a man.
Art Reproduction tend to be terrific concept for decorating as they'll immediately provide beauty, add color and can enhance the actual overlook associated with home, office or even library whilst admire the very best quality duplication of unique artwork.
Oil paintings comes in all shapes and sizes and generally based on a variety of themes that appeal to all tastes. For oil painting, different painting materials are used like canvas and cardboard. Original oil paintings are most valuable art among other existing art, out of them some are valued at millions of dollars.
Gallery should be an internet based photo album who've multiple user support, it provides you with the consumer a chance to create and maintain their own albums through web interface.
You're welcome to reprint these articles on your website and in your e-newsletters free of charge, provided: you don't change the article in any way you include the byline (including a link to our website ) in doing so you agree to indemnify Marketing Scoop and its directors, officers, employees and agents from and against all losses, claims, damages and liabilities which arise out of their use TIP: By viewing and copying the source, you'll be able to retain all formatting.
If you're a big fan of Alexa rankings, you may have noticed some significant changes during the last few weeks. In fact, every website's Alexa ranking has changed based on a new and improved ranking methodology.
As I continue to work with companies seeking to improve the return of their Internet marketing dollars, I've gained a new appreciation for the marriage of search engine marketing and search engine optimization
As someone who makes a living improving search engine rankings, I can tell you that there is a lot of bad information out there about SEO. What if I were to tell you that the road map for achieving top rankings was within your grasp? The holy grail of rankings is not imaginary. As is true with any major success, it leaves clues.
Do I have your attention? Anyone trying to make a living online is interested in one thing, improving conversions. As an Internet marketing veteran, I've seen plenty of web sites and blogs miss one their biggest opportunities for growth. The answer is actually quite simple, making the most of your list.

