MySQL and Perl for the Web

Overview

MySQL and Perl for the Web provides a much-needed handbook for database and Web developers seeking an extensive and detailed guide for using the combination of MySQL and Perl to build dynamic and interactive database-backed Web sites. It shows how to use Perl's DBI database access module, pairing it with with the CGI.pm module that allows Web pages and forms to be generated and processed easily. These tools provide developers with a solid foundation for creating applications that incorporate database content to ...

See more details below
Other sellers (Paperback)
  • All (33) from $1.99   
  • New (7) from $13.17   
  • Used (26) from $1.99   
Sending request ...

Overview

MySQL and Perl for the Web provides a much-needed handbook for database and Web developers seeking an extensive and detailed guide for using the combination of MySQL and Perl to build dynamic and interactive database-backed Web sites. It shows how to use Perl's DBI database access module, pairing it with with the CGI.pm module that allows Web pages and forms to be generated and processed easily. These tools provide developers with a solid foundation for creating applications that incorporate database content to create dynamic, up-to-date Web sites.

The book employs a practical learn-by-doing approach that demonstrates development techniques by building complete applications, not just fragmentary pieces. It shows what to do at each step of the way during the process of building live, working examples. Applications are fully explained so you can understand how they work and apply the techniques they illustrate to your own projects.

Read More Show Less

Editorial Reviews

From The Critics
Illustrates how to use MySQL in tandem with Perl and its DBI module to write web-based database scripts. The author describes the procedures for creating and initializing forms with CGI.pm, writing forms-based applications, automating the form-handling process, performing searches, and securing connections. The final chapter provides an example e-commerce web site. Annotation c. Book News, Inc., Portland, OR (booknews.com)
Read More Show Less

Product Details

  • ISBN-13: 9780735710542
  • Publisher: Sams
  • Publication date: 8/28/2001
  • Series: Landmark Series
  • Pages: 529
  • Product dimensions: 7.00 (w) x 8.90 (h) x 0.90 (d)

Meet the Author

Paul DuBois began his involvement with MySQL after recoiling in horror at the complexities of dealing with a database from one of the larger commercial vendors, and with its customer support mechanism. Turning to MySQL for relief proved to have unforeseen and unexpected consequences: first as the opportunity to contribute to the MySQL Reference Manual, then to writing "MySQL" with New Riders, and most recently to his present employment with NuSphere, a company actively involved in MySQL development, promotion, and training.

Paul's responsibilities and interests have at one time or another involved database development, Web site development and management, mailing list management, system administration, and TCP/IP and AppleTalk networking. He's considered a leader in the MySQL and Open Source communities.

Read More Show Less

Read an Excerpt

Chapter 5: Writing Form-Based Applications

Chapter 4 "Generating and Processing Forms," covered the general techniques involved in creating forms. In this chapter, we'll use those techniques to write several types of form-based applications, and in Chapter 6, "Automating the Form- Handling Process," we'll discuss how you can use information in your database to help you handle forms automatically.

Web programming includes such a diverse range of applications that we can't hope to cover more than a fraction of the possibilities. Nevertheless, there are several recur- ring issues, and the applications in this chapter illustrate a number of useful techniques that you should be able to apply to many of your own projects. Therefore, although useful in their own right, these applications are not just ends in themselves —they serve an illustrative purpose as well. The projects we'll tackle, and some of the techniques they involve, are as follows:

  • A product-registration script that enables customers to register purchases online by visiting your Web site rather than by mailing in a paper form. It shows how to generate and validate a form on the basis of specifications stored in a data structure.
  • A guestbook. I guess every Web programming book has to have a guestbook, so this one does, too. However, our version serves only as a means by which to demonstrate how to incorporate email capabilities into your scripts. The guestbook itself uses email to help keep you apprised of new entries, and we'll cover other ways you can use mail capabilities in your applications. The section also discusses how to set up jobs that execute according to predetermined schedule.
  • A giveaway contest application that enables visitors to your site to submit contest entries. This section covers some basic fraud-detection techniques to help combat ballot-box stuffing, selection of random entries to choose contest winners, and entry summary and expiration methods.
  • A simple poll. We'll develop a script that uses a form to present candidates users can vote for, and that displays a results page showing the current vote totals. The application uses MySQL to count the votes, and the results page uses the current totals in the database so that the results shown are always up to date.
  • Image-storage and image-display scripts. Images are an integral part of many Web applications, which necessitates a method for getting them to your server host and accessing them from within your scripts. To provide support for image use, we'll illustrate how to load images into MySQL two ways:over the Web using a form containing a file-upload field, and from the command line. In addi- tion, this section shows how to display images in Web pages by pulling them from your database.
  • An application that enables you to construct an electronic greeting card interactively and notify the recipient that it's waiting. The card is stored as a database record so that it can be retrieved and displayed later for the recipient. The application also notifies you when the recipient views the card. This application incorporates image-display capabilities and shows how to implement multiple- stage record construction, how to trigger a notification when a record's status changes, and how to handle removal of expired cards.
The applications in this chapter have very different purposes, but share certain common characteristics. Generally, you'll find that form-based programs involve the following steps, although the steps vary in complexity from application to application, depending on your goals and requirements:
  • Generate a form to solicit the information you want to collect from the user. Some forms are relatively trivial: Our polling application presents a form containing nothing more than a set of radio buttons listing the candidates and a Submit button. The user clicks one time to pick a candidate, a second time to submit the vote, and that's it. Other forms are more extensive: The product- registration application has many fields because we need to gather information about both the product being registered and the user who's registering it.
  • Validate the form's contents when the user fills it in and submits it. Form validation can be minimal or quite extensive. You may have fields that are required but were left blank by the user, or fields that must contain a certain kind of information but were filled in incorrectly. In such cases, the user must submit additional or revised information. You'll find it necessary to inform the user that the form cannot be processed, as well as what should be done to correct any problems. We'll demonstrate several feedback techniques over the course of the chapter.
  • Store the form submission. Some applications store form information in a file or mail it somewhere for further processing. This being a book on MySQL, we will of course focus on using a database as the primary storage mechanism for each application.
  • Generally, you provide some kind of feedback to the user after a form submis- sion has been received and processed. This can be quite simple, such as a thank you message expressing appreciation for the user's participation in a poll or survey, or a brief acknowledgement that the submission was received. Or you may redisplay the information to provide confirmation to the user that it was received properly.
A small reminder before you proceed:You'll find the source code for the scripts developed here in the webdb software distribution that accompanies this book. You can get it at the following Web site:
http://www.kitebird.com/mysql-perl/

You may find it useful to install each script and try it out first before you read the section that describes how it works.

Product Registration

Registration applications serve many purposes. You can use them to allow people to register products they have purchased, sign up for conferences, request a catalog, add themselves to a mailing list, and so forth. The obvious advantage over paper forms for you when you receive a registration from someone is that you needn't re-key the information to get it into your database —the Web application inserts it for you. An advantage for users is instant transmission of their registration information without having to dig up a stamp or put the registration form in the mail.

In this section, we'll write a script, prod_reg. pl , that collects product registrations over the Web. Generally, this kind of registration form has, at a minimum, fields to identify the product and the customer, and our application will confine itself to gathering that kind of information. Many registration forms have additional fields for demographic information such as household income, type of employment, or how the product will be used. We'll skip that stuff;you can add it later if you like.

To process registrations, we need a database table in which to store registration records and an application that collects information from customers and inserts records into the table. The table we'll use looks like this...

Read More Show Less

Table of Contents

1: Getting Connected—Putting Your Database on the Web.

2: Performance Issues.

3: Form Processing.

4: Searching.

5: Session Management and Authentication.

6: Security and Privacy Considerations.

7: E-Commerce Topics.

8: XML.

Appendix A: Obtaining Software.

Appendix B: Other References/Further Reading.

Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)
Sort by: Showing all of 3 Customer Reviews
  • Anonymous

    Posted Sat Nov 30 00:00:00 EST 2002

    Get the Power

    If you want to create refined web-based applications, get this book. Paul DuBois does an excellent job of presenting enormously complex material without putting the reader to sleep. The book explains both how it creates modules for a program, and why a given method was chosen over other available methods. This offers comprehension to add to the reader's technical proficiency, and really sets this book apart from reference books that simply list code along with its result. I reccomend this book highly. If you have read MySQL by Paul DuBois, this is even better because it offers real-world applicability, and gets you coding and creating quickly.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted Tue Feb 12 00:00:00 EST 2002

    Great book

    This is one of the better programming books that I have read in a long time. I am about 3/4 of the way through it and all of the examples are bang on. The best part about this book is all of the different options that are explained for configuring Apache and Perl. If one way wouldn't work, then I was easily able to find another way that did. About the only bad thing was the small code snippets. I would have preferred to see the entire program in the book, instead of having to download it from the web site. All in all, that was a small price to pay for a quality book.

    Was this review helpful? Yes  No   Report this review
  • Anonymous

    Posted Sun Nov 04 00:00:00 EST 2001

    I tell you what

    If you know some Perl and some MySQL, please, DO by 'MySQL and Perl for the Web' by Paul DeBois and figure out how those fancy web applications out there are made and learn how to be able to write one. Paul's 'MySQL and Perl for the Web' touches upon some topics that NONE OF THE BOOKS out there ever covered in so much details. The style and examples are amazing. He makes use of Perl5's Object Oriented features which itself tells you that it's a professional textbook for professional web-programmers. The book teaches you neither Perl nor MySQL from basics. It assumes you already have some basic knowledge of Perl and MySQL. So it starts off at the most fun part without waisting neither his nor the readers' time. Here I'll go over the chapters in case the table of contents don't tell you much (they didn't to me). Chapter 1 and chapter 2 go over some basic things that you need in order to understand and/or try out the examples in the book. Chapter 2 goes over configurting your MySQL and Apache. I believe if you are on a hosting service, this should've been done for you already. It also teaches you to write 'A Simple Web-Based Application - To-do List Maintenance'. Although the application doesn't require a lot of brains to create, but it does cover some basic concepts that you'll be using all the time in web-programming. Chapter 3 gives some information on 'Improving Performance with mod_perl' and how to write scripts that work in mod_perl compiled servers. Chapter 4, 'Generating and Proccessing Forms' goes over 'Form Anatomy' and does introduce some concepts of 'Form Desgin Issues' Chapter 5, 'Writing form-Based applications' is probably the wealthiest chapter of the book. Following sections are available under this chapter: 'Product registration', 'Using Email from Within Applications', 'Running a Giveaway contest', 'Conducting a Poll', 'Storing and Retriving Images', 'Electronic Greeting Cards - Send a Friend a Greeting'. This chapter lasts over 80 pages. Chapter 6, 'Automating the Form-Handling process' introduces some concepts that you can make use of in order to automate the form handling process through the use of MySQL's table metadata, which is available through DESC table_name ( or SHOW COLUMNS FROM table_name ) query. Using his concept I introduced a new module to CPAN.org, MySQL::TableInfo. Chapter 7, 'Performing Searches' covers 'Writing a Form-Based Serch Application' and 'Extending' it. It also introduces the concept of 'Link-Based Navigation'. It also teaches you how to split the results of the search over several pages; suppose you have a result of 100 rows in your search, and you show only 20 results at a page, and provide [previos] and [next] links so that users could navigate over your pages. Neat, isn't it? Cahpter 8, 'Session Management' was the one I have been wating for so long. It goes over some 'State Maintenance Techqniques' used in web applications, then introduces the most favorite one, 'Active Client Identification' method. The sections the chapter covers are: 'State Maintenance Techqniques', 'Implementing Session Support', 'Expiring Sessions', 'Storing User Prefernces', 'Implementing Resumable Sessions' and 'When Sessions aren't enough' Chapter 9, 'Security and Privacy' teaches you the ways of precaution you could take against 'bad guys' ( hackers? ) to insure the security of your site/database. Also shows you how to write a login page to provide access to some sensitive information using the techniques he just mentioned. Chapter 10, 'E-Commerce Applications' covers such topics as Shopping carts, credit card validation and in the end of the chapter completed a fully operating commercial web-site. Although the book concentrates on MySQL, I wrote several applications that make use of Berkeley Database using the same techniques as Paul suggested. I tell you, I lerned a lot....

    Was this review helpful? Yes  No   Report this review
Sort by: Showing all of 3 Customer Reviews

If you find inappropriate content, please report it to Barnes & Noble
Why is this product inappropriate?
Comments (optional)