Lab 5

Lab Exercise: Design a User Login Page Using Authentication with a Database Table

Objective: Be familiar with user authentication

Steps:
  1. Create a subfolder named as lab5 in your web folder (~/public_html/csc4341). After that, copy the sample files from the shared folder located at the CSC server:
    cp /shared/csc4341/lab5/* ~/public_html/csc4341/lab5
  2. The starting page in your lab5 folder would be login.html.
  3. To authenticate a user, you need to have a database table with user email and password as well as other information. In the subfolder, there is a file named user_table.sql which contains lines of scripts for creating such a user table. You need to run the script on your own database to create the table.
  4. db.php contains database connection information. Make changes to them to connect to your own database.
  5. After that, manually insert some user data into the users table. Note the password data should be encryped using md5 method. The following is an example for inserting a user into the users table.
    mysql> insert into users (user_name, user_email, user_password, joining_date) values ('jamoore', 'jamoore@txwes.edu', md5('csc1310'), now());
    Query OK, 1 row affected (0.00 sec)
    
    mysql> select * from users;
    +---------+-----------+-------------------+----------------------------------+---------------------+
    | user_id | user_name | user_email        | user_password                    | joining_date        |
    +---------+-----------+-------------------+----------------------------------+---------------------+
    |       1 | yzhang    | yzhang@txwes.edu  | d167119c3234bd9b478c932ebf131a66 | 2016-10-20 23:43:55 |
    |       2 | sshree    | sshree@txwes.edu  | d167119c3234bd9b478c932ebf131a66 | 2016-10-20 23:44:30 |
    |       3 | pgautam   | pgautam@txwes.edu | d167119c3234bd9b478c932ebf131a66 | 2016-10-20 23:44:49 |
    |       4 | jamoore   | jamoore@txwes.edu | 54ff7d4facb506eafd9a4e878d7cac10 | 2016-10-22 23:01:19 |
    +---------+-----------+-------------------+----------------------------------+---------------------+
    4 rows in set (0.00 sec)
    
    
  6. Once a user is authenticated again the data stored in the database, the log page creates a PHP session and redirect to member protected pages.
  7. Study the sample programs to understand authentication process. Feel free to modify the styles and heading of the web table.
  8. Post your work on your web site.