Cover image for Sams teach yourself CGI in 24 hours
Title:
Sams teach yourself CGI in 24 hours
Author:
Colburn, Rafe.
Personal Author:
Publication Information:
Indianapolis, Ind. : Sams Pub., [2000]

©2000
Physical Description:
xvii, 490 pages : illustrations ; 23 cm.
Language:
English
ISBN:
9780672318801
Format :
Book

Available:*

Library
Call Number
Material Type
Home Location
Status
Central Library TK5105.565 .C649 2000 Adult Non-Fiction Central Closed Stacks
Searching...

On Order

Summary

Summary

Sams Teach Yourself CGI in 24 Hours teaches you the next step beyond simple HTML Web pages. This new edition covers implementing CGI with both C and Perl, and it discusses CGI's relative strengths and weaknesses in comparison with other Web programming technologies like JavaScript, Java, and PHP. The book takes you from the basics of CGI--learning, for example, how to implement and customize existing CGI programs that have been written by others--to the point where you can use CGI to create your own programs from scratch. The book also provides numerous real-life examples of CGI scripts, such as database search tools, survey forms, interactive games, order forms, guest books, and more.


Author Notes

Rafe Colburn is a Web technologist at TriNet Services, where he specializes in designing large corporate Internet and Intranet sites. He has written several books for Sams including Teach Yourself CGI Programming in a Week and Teach Yourself Netscape 4 Web Publishing in a Week.


Table of Contents

Introductionp. 1
Part I An Introduction to CGIp. 3
Hour 1 Overview of CGI Programmingp. 5
Types of Web Applicationsp. 6
A History of CGIp. 6
What Is a CGI Program?p. 7
How CGI Programs Workp. 8
Pros and Cons of CGIp. 11
CGI Programming Languagesp. 12
Summaryp. 15
QandAp. 16
Workshopp. 16
Hour 2 Setting Up Your CGI Environmentp. 17
The Web Server Itselfp. 17
Web-Server Operating Systemsp. 20
The CGI Environmentp. 21
Web Serversp. 21
Setting Up Your CGI Development Environmentp. 23
Summaryp. 30
QandAp. 31
Workshopp. 31
Hour 3 Downloading, Installing, and Debugging CGI Scriptsp. 33
Downloading Scripts From the Internetp. 34
Installing a Downloaded Scriptp. 36
Example: Downloading and Installing a Guestbook Scriptp. 36
Debugging CGI Scriptsp. 39
Tools and Techniques for Debugging Your Program Codep. 44
Summaryp. 48
QandAp. 48
Workshopp. 48
Hour 4 Writing Your First CGI Programp. 51
Parts of CGI Programsp. 52
A URL-Redirection Programp. 55
Working With Files in Perlp. 58
Loops in Perlp. 61
The if Statementp. 62
Perl Expressionsp. 64
Summaryp. 65
QandAp. 65
Workshopp. 66
Part II Capturing User Inputp. 67
Hour 5 Creating HTML Formsp. 69
The [FORM] Tagp. 70
The [INPUT] Tagp. 71
Other Form Fieldsp. 78
Workshop: Building an Entire Formp. 80
Summaryp. 83
QandAp. 83
Workshopp. 84
Hour 6 Processing Inputp. 85
A Little Bit About HTTPp. 85
Handling Script Argumentsp. 88
Processing Form Datap. 90
Using CGI.pm to Decode Form Datap. 94
Sending Input to CGI programs via Extra Path Informationp. 96
CGI Environment Variablesp. 97
Summaryp. 98
QandAp. 99
Workshopp. 99
Hour 7 Validating User Inputp. 101
Using JavaScript for Form Validationp. 101
Designing Easily Validated Formsp. 104
Incorporating Validation into the Form-Processing Codep. 105
An Example of Form Processingp. 106
Validating Valuesp. 113
Summaryp. 117
QandAp. 118
Workshopp. 118
Hour 8 Creating an Email Feedback Formp. 119
What Kinds of Applications Entail Sending Email?p. 120
How Email Worksp. 120
Example: Sending Email from a CGI Scriptp. 125
Using Blatp. 131
Summaryp. 134
QandAp. 134
Workshopp. 135
Part III CGI Programming Languages and Toolsp. 137
Hour 9 CGI and Simple Shell Scriptingp. 139
Writing Shell Scriptsp. 140
Decoding Form Datap. 143
Working with Query Stringsp. 143
Un-CGIp. 145
Summaryp. 149
QandAp. 149
Workshopp. 149
Hour 10 Perl--The Big Kahuna of CGI Programmingp. 151
CGI.pmp. 151
Accessing CGI.pm from Your Programp. 152
Decoding Form Data via CGI.pmp. 153
Generating HTTP Headers and HTML Tags via CGI.pmp. 157
cgi-lib.plp. 161
Handling Errors with CGI::Carpp. 162
Resources for Perl Programmersp. 164
Summaryp. 167
QandAp. 167
Workshopp. 167
Hour 11 Other Popular CGI Programming Languagesp. 169
Will My Favorite Language Work for CGI?p. 169
Writing CGI Programs in Cp. 170
The cgic Libraryp. 171
A C Examplep. 176
Writing CGI Programs in Pythonp. 179
A Python Examplep. 181
Summaryp. 183
QandAp. 183
Workshopp. 183
Hour 12 Pros and Cons of Alternate Technologiesp. 185
Looking Backp. 186
Types of CGI Alternativesp. 187
Active Server Pagesp. 188
Allaire ColdFusionp. 191
The Apache mod_per1 Modulep. 192
PHPp. 194
Server-Side Javap. 196
Summaryp. 197
QandAp. 198
Workshopp. 198
Part IV Building Basic CGI Applicationsp. 201
Hour 13 Using Flat Files for Data Storagep. 203
What Is a Database?p. 204
Flat-File Databasesp. 204
File Operationsp. 206
Building a Database Applicationp. 208
Summaryp. 222
QandAp. 223
Workshopp. 223
Hour 14 Creating a CGI-Based Message Boardp. 225
The Structure of the Applicationp. 225
The File Formatp. 226
The Display Scriptp. 227
The Posting Scriptp. 235
Summaryp. 242
QandAp. 242
Workshopp. 242
Hour 15 Session (State) Managementp. 243
Why Use Session Management?p. 244
Basic Authenticationp. 245
Hidden Fields in Formsp. 246
Hidden Form Fields Examplep. 247
Using Cookiesp. 250
Session Management with Cookiesp. 257
Summaryp. 262
QandAp. 262
Workshopp. 263
Hour 16 Building a Simple Shopping Cartp. 265
How the Sample Shopping Cart Worksp. 266
The Catalogp. 267
The Contents of the Shopping Cartp. 272
Checkoutp. 277
Summaryp. 283
QandAp. 284
Workshopp. 284
Hour 17 Content Publishing with CGIp. 287
Why Content Publishing?p. 287
Types of Content Publishing Systemsp. 288
Data Storage for Content Publishing Systemsp. 289
A Content Publishing Examplep. 290
Third-Party Content Management Systemsp. 299
Summaryp. 301
QandAp. 301
Workshopp. 302
Part V Integrating Databases and CGIp. 303
Hour 18 Working with Relational Databasesp. 305
The Relational Database Modelp. 305
Structured Query Languagep. 307
Database Designp. 310
Relational Data Typesp. 315
Summaryp. 317
QandAp. 318
Workshopp. 318
Hour 19 How to Use the Structured Query Languagep. 319
Structured Query Languagep. 320
Database Interfacesp. 329
ODBCp. 330
DBI and DBDp. 330
Summaryp. 333
QandAp. 334
Workshopp. 334
Hour 20 Creating an Online Storep. 335
The Database Designp. 335
The Catalog Scriptp. 339
The Shopping Cart Scriptp. 344
The Checkout Scriptp. 348
Summaryp. 355
QandAp. 355
Workshopp. 355
Part VI Additional CGI Tips and Tricksp. 357
Hour 21 Working with HTTPp. 359
HTTP Basicsp. 359
What Takes Place During an HTTP Sessionp. 360
Server Response Codesp. 364
Response Headersp. 366
NPH Scriptsp. 367
Content Typesp. 368
Secure Connectionsp. 371
Summaryp. 372
QandAp. 372
Workshopp. 373
Hour 22 Securing CGI Scriptsp. 375
Why Security?p. 376
Securing Your Web Serverp. 378
Common CGI Security Holesp. 381
Safe Programmingp. 385
Summaryp. 386
QandAp. 387
Workshopp. 387
Hour 23 Creating Custom Error Documentsp. 389
What Is an Error Document?p. 389
Configuring Your Web Server for Custom Error Documentsp. 392
Using HTML to Create a Basic Error Documentp. 394
Using CGI to Create an Advanced Error Documentp. 395
Handling an "Unauthorized" Errorp. 404
Summaryp. 406
QandAp. 406
Workshopp. 406
Hour 24 Server Side Includesp. 407
How Server Side Includes Workp. 408
Setting Up Your Web Server for SSIp. 408
Using SSI Directivesp. 410
Designing Pages Using SSIp. 417
XSSIp. 421
Summaryp. 423
QandAp. 423
Workshopp. 424
Appendixesp. 425
Appendix A Answersp. 427
Appendix B MIME Typesp. 439
Appendix C Response Codes and Reason Phrasesp. 443
Appendix D Environment Variables and Request Headersp. 449
Appendix E Summary of Regular Expressionsp. 455
Appendix F The ASCII Character Tablep. 459
Indexp. 465

Google Preview