Introduction | p. xvii |
CGI: An Introduction | p. 1 |
CGI and the Web | p. 3 |
What Is CGI? | p. 4 |
Why Use CGI? | p. 5 |
Why Is CGI Important to the Web Designer? | p. 7 |
Who Uses CGI? | p. 8 |
CGI Basics | p. 9 |
What You Need to Run CGI Applications | p. 10 |
CGI Server Requirements | p. 11 |
Getting Started with CGI | p. 12 |
Creating Your cgi-bin | p. 12 |
CGI Programming Languages | p. 16 |
Your Choices | p. 16 |
The Most Popular CGI Language: Perl | p. 16 |
Preparing Your Web Page for CGI | p. 18 |
Summary | p. 21 |
Writing Your CGI Application | p. 23 |
Planning Ahead Is Important | p. 24 |
Using Multiple Languages | p. 24 |
Using Multiple HTML Pages | p. 25 |
Adopting Proper Form Design | p. 28 |
Planning the Database Design | p. 29 |
Writing Pseudocode | p. 32 |
Learning the Programming Basics | p. 35 |
Understanding the Difference Between Programs and Scripts | p. 36 |
Learning the Perl Basics | p. 36 |
Summary | p. 48 |
Your First CGI Application | p. 49 |
Creating Your Application Using Perl | p. 50 |
Adding Comments to Your Application | p. 50 |
Creating Your Application on a PC or Mac | p. 53 |
Creating Your Application on a UNIX Server | p. 62 |
Changing the Permissions of Your Application | p. 64 |
Starting Your CGI Application Using Perl | p. 66 |
Finding Perl on Your Server | p. 66 |
Using the Interpreter's Location in Your Application | p. 68 |
Writing Your Perl Code | p. 69 |
Running Your CGI Application | p. 75 |
Using the URL to Run the Application | p. 75 |
Using a Test HTML Form to Run the Application | p. 76 |
Summary | p. 77 |
Basic Data | p. 79 |
Getting the Data from Vistors to Your Web Page | p. 81 |
Gathering Data from Your Visitors | p. 82 |
Using Data Labels | p. 82 |
Using Name Attributes or HTML Labels | p. 83 |
Developing Your HTML Form | p. 85 |
Using Text Input Fields | p. 85 |
Using Selected Choice Inputs | p. 93 |
Creating Action Buttons | p. 100 |
Adding Default Values to Your Forms | p. 106 |
Adding Links to Your Forms | p. 108 |
Using Environment Variables | p. 111 |
Using Post versus Get | p. 111 |
Determining Browser and Platform Information | p. 117 |
Determining Navigation Information | p. 119 |
Viewing All Environment Variables at Once | p. 120 |
Summary | p. 121 |
Getting the Data Into Your CGI Application | p. 123 |
The Importance of the Data in Your Application | p. 124 |
The Ability to Interact | p. 124 |
The Means of Communicating with Your Visitors | p. 124 |
Inputting User Data | p. 125 |
Parsing Data from Forms and Links | p. 125 |
Inputting Data from Environment Variables | p. 136 |
Inputting Data Yourself | p. 137 |
Inputting Data from Scalars | p. 138 |
Inputting Data from Arrays | p. 139 |
Inputting Data from Hashes | p. 142 |
Dealing with Potential Problems | p. 145 |
Incorrect Input from Your Users | p. 145 |
Faulty Data that You Input | p. 146 |
Summary | p. 147 |
Scalars | p. 148 |
Storing Scalar Information | p. 149 |
Initial Data | p. 149 |
Results of Operations | p. 150 |
Using Numbers as Scalar Variables | p. 152 |
Addition | p. 152 |
Subtraction | p. 154 |
Multiplication | p. 155 |
Division | p. 159 |
Using Multiple Operators | p. 162 |
Using Strings as Scalar Variables | p. 164 |
Connecting Strings | p. 164 |
Repeating Strings | p. 166 |
Assigning Values to a Variable | p. 167 |
Manipulating Variable Values | p. 168 |
Summary | p. 172 |
Arrays | p. 173 |
Splitting a Scalar Into an Array | p. 174 |
Reasons for Splitting a Scalar | p. 174 |
The Process of Splitting a Scalar | p. 175 |
Determining the Length of an Array | p. 177 |
Using a Scalar Variable | p. 177 |
Using the Index Number | p. 179 |
Retrieving Array Data | p. 181 |
Retrieving a Specific Item | p. 182 |
Retrieving Multiple Items | p. 186 |
Modifying an Array | p. 191 |
Modifying the Entire Array | p. 191 |
Adding Elements to an Array | p. 195 |
Removing Array Elements | p. 199 |
Replacing Array Elements | p. 203 |
Reversing the Order of Elements | p. 206 |
Manipulating Arrays | p. 207 |
Combining Arrays | p. 207 |
Sorting Arrays | p. 208 |
Summary | p. 209 |
Hashes | p. 210 |
Checking for the Existence of a Key | p. 211 |
Why Checking Is Important | p. 211 |
How to Check for a Key | p. 211 |
Retrieving Hash Values Using Keys | p. 214 |
Retrieving a Single Value | p. 214 |
Retrieving Multiple Values | p. 216 |
Retrieving All the Hash Data | p. 218 |
Finding All Hash Values | p. 218 |
All Hash Keys | p. 219 |
Retrieving Specific Keys and Values | p. 221 |
Retrieving the First Key and Value | p. 221 |
Retrieving Each Key and Value | p. 224 |
Retrieving Key-Value Pairs with the Keys Function | p. 225 |
Removing Key-Value Pairs | p. 228 |
Summary | p. 232 |
Conditional Statements | p. 233 |
Comparing Values | p. 234 |
Number Comparison | p. 234 |
String Comparison | p. 235 |
Evaluating without Comparisons | p. 237 |
Checking Multiple Comparisons | p. 237 |
Creating Your Conditional Statement | p. 239 |
Using Conditional Statement Blocks | p. 245 |
The if/unless Statement | p. 245 |
The while/until Statement | p. 248 |
The do {} while/until Statement | p. 251 |
The for Statement | p. 255 |
The foreach Statement | p. 258 |
Nested Conditional Statements | p. 260 |
Summary | p. 262 |
Advanced Data | p. 263 |
Handling Data with Regular Expressions | p. 265 |
Using Regular Expressions | p. 266 |
Matching Text Patterns | p. 267 |
Single Character Patterns | p. 267 |
Group Patterns | p. 271 |
Anchor Patterns | p. 274 |
Precedence | p. 277 |
Using the Matching Operator | p. 277 |
Choosing a Different Target | p. 278 |
Ignoring String Case | p. 280 |
Using Different Delimiters | p. 282 |
Variable Interpolation | p. 284 |
Making Substitutions with Regular Expressions | p. 287 |
Advanced Substitutions | p. 288 |
Using the Split Function | p. 291 |
Summary | p. 294 |
Subroutines | p. 295 |
Creating a Subroutine | p. 296 |
A Basic Subroutine | p. 296 |
A Subroutine that Requires Input | p. 297 |
Storing a Subroutine | p. 298 |
Calling a Subroutine | p. 299 |
Calling a Basic Subroutine | p. 300 |
Calling a Subroutine that Requires Input | p. 300 |
Calling a Subroutine from an External File | p. 303 |
Subroutine Return Values | p. 304 |
Using the Subroutine Return Value | p. 305 |
Manually Setting the Return Value | p. 307 |
Summary | p. 309 |
Retaining Visitor Data | p. 310 |
Creating Hidden Fields | p. 311 |
Adding Hidden Fields to Your Form | p. 311 |
Using a Hidden Field to Store Collected Data | p. 313 |
Understanding Cookies | p. 316 |
Setting Cookies | p. 317 |
Reading Your Cookies | p. 325 |
Tossing Your Cookies | p. 326 |
Putting It All Together | p. 328 |
Summary | p. 332 |
Outputting Data | p. 333 |
Generating STDOUT Output | p. 334 |
Normal Output Using print | p. 334 |
Formatted Output Using printf | p. 336 |
Generating HTML Formatted Output | p. 339 |
Adding HTML Formats to Output | p. 339 |
Printing Multiple Lines | p. 340 |
Image and Path Links | p. 342 |
Generating Header and Footer Subroutines | p. 343 |
Creating Header and Footer Subroutines | p. 344 |
Calling Header Subroutines | p. 346 |
Calling Footer Subroutines | p. 347 |
Generating Table and List Outputs | p. 348 |
Outputting a Hash as a Table | p. 349 |
Outputting an Array as a List | p. 351 |
Formatting Numbers and Strings | p. 352 |
Printing Formatted Data | p. 353 |
Formatting Numbers as Dollars and Cents | p. 354 |
Padding Numbers | p. 356 |
Summary | p. 357 |
Formats | p. 359 |
Using Formats | p. 360 |
Defining a Format | p. 361 |
Invoking a Format | p. 363 |
Using Fields | p. 364 |
Text Fields | p. 368 |
Numeric Fields | p. 369 |
Multiline Fields | p. 370 |
Filled Fields | p. 372 |
Using the Top-of-Page Format | p. 373 |
Changing Format Defaults | p. 376 |
Changing the Format Names | p. 376 |
Changing the Page Length | p. 378 |
Summary | p. 379 |
Files and Directories | p. 380 |
Using Files | p. 381 |
Opening Files | p. 381 |
Closing Files | p. 386 |
Writing to Files | p. 387 |
Reading Data from Files | p. 388 |
Exclusive File Access | p. 390 |
Renaming Files | p. 391 |
Removing Files | p. 394 |
Checking the Status of Files | p. 395 |
Using Directories | p. 398 |
Opening Directories | p. 398 |
Closing Directories | p. 399 |
Viewing Directory Contents | p. 400 |
Changing the Directory | p. 401 |
Creating New Directories | p. 402 |
Removing Directories | p. 403 |
Using File and Directory Operations | p. 404 |
Verifying Files and Directories | p. 404 |
Changing Permissions In Your Application | p. 405 |
Eliminating Characters | p. 406 |
Summary | p. 408 |
Appendixes | p. 409 |
Debugging Your Application | p. 411 |
Understanding Debugging | p. 412 |
Deciphering Error Messages | p. 413 |
The Dreaded 500 Internal Server Error | p. 414 |
403 Forbidden | p. 419 |
The Document Contained No Data | p. 419 |
404 File Not Found | p. 423 |
Using Other Valuable Debugging Tools | p. 424 |
Using Error Subroutines | p. 424 |
Summary | p. 431 |
What's On the CD-ROM | p. 432 |
Running the CD | p. 433 |
Linux | p. 433 |
Windows 95/98/2000/NT | p. 433 |
The Prima License | p. 434 |
The Prima User Interface | p. 434 |
Resizing and Closing the User Interface | p. 434 |
Using the Left Panel | p. 434 |
Using the Right Panel | p. 435 |
Index | p. 436 |
Table of Contents provided by Syndetics. All Rights Reserved. |