In class Wednesday, I was unable to remember the other pattern matching function. The one I was thinking of was
split(). It is particularly useful for parsing data stored in files in which the fields are seperated by delimeters.
Consider the following example of a php script that uses split.

<HTML>
<HEAD>
   <TITLE> Example of Split and Files</TITLE>
</HEAD>
<BODY>
   <?  // the following statement opens the files called output.txt
         // and reads each line of the file into an array called $readfile
        // Each line will be accessed by it's position in the array
        // $readfile[0] would be the first line because the array begins at 0
       // rather than 1
     $readfile = file("output.txt");
      // Create a loop that will read all elements of the array and print out
      // each field of the tab-delimited text file
  for ($k=0; $k<=count($readfile)-1; $k++)
   { $fields = split("\t",$readfile[$k]); print("$fields[0] and $fields[1] and $fields[3]<br>"); }
   ?>
</BODY>
</HTML>

Now,  here is the mid term programming assignment.

Create a form that asks the user to create a user ID and password.
The user ID and password must conform to a set of rules to be valid.
Generate an appropriate message to output upon receiving an invalid user ID or password.

Use the following rules fotr these input fields:
   a. User IDs must start with an alpha character (a-z) and be at least three characters.
       Uppercase letters are not allowed any where in the user ID. User IDs can not have
        spaces, or other special characters such as ("!", "@", "#", or "$"). A  user ID may
        however, contain a hyphen "-".  Finally user IDs can not be any of the following
        reserved IDs "root", "admin", or "operator" .
    b. The password field must be at least six characters long. Passwords must be valid
         letters or numbers and must not include any of the special characters ("!", "@", "#", or "$").
         Valid passwords may contain spaces and hyphens.

Your script should also check to see if the ID that is entered is already in use by checking
a file of  user IDs and passwords. If the ID exists already, then the user is prompted with
an appropriate message and asked to enter a new ID. It does not matter if passwords are
alerady in use by other users. If the ID is not in use,  the user ID and Password should be
entered in the file and an appropriate message  should be sent back to the screen indicating a successfull
ID and password were entered.

Bonus: This will substitute for the 6th program assignment if done. If not then you can do
the sixth assignment when posted.

Write a script to encrypt the ID and password in the password file. This means you will need to encrypt it
after it is checked against the password/id file. This should be done on a line by line basis
in the file. In other words, decrypt the user id from the password file compare it to the
user specified file and if it is not equal then go on to the next line of the file . If no match is
found then both ID and password  should be encrypted  and stored in the file. Then  write a  second
html form and necessary php script to allow a user  to enter a user ID and password in text form
and then check against this file ( encrypted) to see if the user ID exists and if the password supplied
is correct. Appropriate encryption/decryption must take place at the appropriate place
regarding the password file is encrypted.

Have fun!