PHP & SESSION MANAGMENT ASSIGNMENT -
This assignment looks at using PHP for creating cookies and session management.
Class Exercise - Web Project: Member Registration/Login
This exercise will cover adding data connectivity to dynamic web pages, implementing login, registration and member pages with session management using sessions. A solution is provided but you should first attempt the exercise yourself.
1. Create a database called cartdb and add the customer table with following fields
Filed Name
|
Data Type
|
Other Info.
|
First_Name
|
Varchar(20)
|
Not Null
|
Last_Name
|
Varchar(20)
|
Not Null
|
Phone
|
Varchar(20)
|
Not Null
|
Password
|
Varchar(20)
|
Not Null
|
Email
|
Varchar(30)
|
Primary Key
|
Note: We will be using the email address as the primary key to avoid complexity.
2. Modify the given PHP script (in attached file) (register.php) to insert customer details to the customer table. Use register.htm to input the values.
Note: 'conn_db.php' is used to connect to the database - replace user/password with correct values.
3. Modify the given PHP script (login.php) using login.htm to validate the user name and password with the database. Your script should also register a new session if the user is a valid user and direct the user to the member page, which will display a greeting to the user. Re-direct the user back to the login page.
4. Use logout.php to destroy the current session and log the user out.
Activity - Cookie
- Capture the customer id in a cookie
- On the page which displays the customer id, display another form (radio button) asking if the customer wishes to receive a newsletter.
- When customer submits response, a PHP script should use the cookie to access and update that customers record in the database.
You will need to create the following 4 files.
1. createDb.php
2. Screenshot: custdetails.htm
3. Screenshot: custinsert.php
4. Screenshot: custupdate.php
Discussion -
1. Discuss the purpose of HTTP with reference to its advantages and disadvantages, how it is useful in developing web applications, it's limitations in web applications.
2. Review and discuss how your project 3 (on server-side scripting) can utilise session management and statelessness. List the purpose of session management and stateless programming.
3. Discuss how you might implement web authentication and security.
Attachment:- Assignment File.rar