User Authentication with DB Cs346 Fall 2010
Requirements Web site is for registered users only – Username and password – Password is encripted
Design Database student – Table auth_user – Re-use m12 scripts to create the table MVC – GUI: xhtml for registration entry – PHP: process the input and insert the entry into DB table auth_user – DB: auth_user – GUI: xhtml for existing user login – PHP: process the username-password, query auth_user
Development stages
Specify name of table and # columns
Define field for auth_user
Add table ‘auth_user’ to DB ‘student’ The above message was generated by the PHP sript. Is it really true? Use m11 script to list tables
Verify that table ‘auth_user’ is created etc. Information_schema has too many attributes
New User Registration
One entry added
Is the entry really there in DB? Use MySQL Console Write a PHP script to query the database
mysql> show databases; | Database | | information_schema | | books | | cs346 | | ex04a | | mailinglist | | mysql | | products | | student | | testdb1 | rows in set (0.00 sec) mysql> use student; Database changed mysql> show tables; | Tables_in_student | | auth_user | | my_music | rows in set (0.00 sec)
mysql> use student; Database changed mysql> show tables; | Tables_in_student | | auth_user | | my_music | rows in set (0.00 sec) mysql> SELECT * FROM auth_user; Empty set (0.00 sec) mysql> SELECT * FROM auth_user; | f_name | l_name | username | password | | John | Doe | john.doe | *54B88827AF6DA4FCE049F501D462BE6A9F7EF979 | row in set (0.00 sec) mysql>
Existing User Login
Existing User Login - successful
Existing User Login - Failure
Next Upload to remote server Testing – Repeat all the steps in the local server: Create table auth_user Enter new registrations Authenticate the users
Add a 2 nd New Registration
ok
success