dcsimg
Click Here!
Click Here!

Perl Primer Eleven Assignment
A Possible Answer

     First off, you have to put in another form input item on the HTML code to accept the second password. That would look something like this:

<INPUT TYPE="text" SIZE="25" NAME="pw2">

     You then have to put in a second password in the PERL script and then test for both. You can do it separately, but testing for both in one shot is a whole lot easier. Notice that each test is within its own set of (parentheses) and && is between then showing both conditions must be met. My changes are in bold.


$password = "cow";
$password2 = "tree";


    if(($password eq $FORM{pw}) && ($password2 eq $FORM{pw2}))

    {
    $file = "correct.html";
    open(FILE, $file);
    while(<FILE>)
       {
       print $_;
       }
    close(FILE);
    }

    else
    {
    print "Content-type: text/html\n\n";
    print "<HTML>";
    print "<TITLE>Wrong!</TITLE>";
    print "<BODY BGCOLOR=#FFFFCC>";
    print "<CENTER><FONT COLOR=red Size = +4> Nope!</FONT></CENTER><P>";
    print "Click BACK to try again";
    print "</BODY>";
    print "</HTML>";
    }





Close this window to return to the Primer