Microsoft Word - Sam's Teach Yourself MySQL in 21 Days - SAMS.doc

(singke) #1


The script that is called when a user clicks the Submit button is Login.pl. This script will take the
values in the Username and Password box and validate that they match against the database. If a
match is found, the requested Web page will be generated; if not, the user will be asked to log in again.
Listing 21.4 is the complete listing of Login.pl.
Listing 21.4 Script for User Log In


#!/usr/local/bin/perl


&GetFormInput;


The intermediate variables below


#make your script more readable


but somewhat less efficient


#since they are not really necessary.


$Username = $field{'Username'} ;


$Password = $field{'Password'} ;


$message = "" ;


$found_err = "" ;


$errmsg = "

Field 'Username' must be filled in.

\n" ;


if ($Username eq "") {


$message = $message.$errmsg ;


$found_err = 1 ; }

Free download pdf