Asgn2 Spec

download Asgn2 Spec

of 3

Transcript of Asgn2 Spec

  • 8/6/2019 Asgn2 Spec

    1/3

    CSC2720 Assignment #2 Due: 26th Feb 2010

    Objective

    The objective of this assignment is to let you practice using different methods to maintain application

    states across multiple server-side scripts.

    Specification

    Let M= number of items to be listed per page by "list.php".

    Implement four PHP scripts that behave similarly to

    1) http://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/login.php

    - If the request method is POST

    o Retrieve the user-id and password from the request

    o If the user-id and the password pass the authentication

    Display a welcome message

    Else

    Display an error message and ask the user to re-enter the user-id and password

    - If the request method is GET

    o If a user is already logged on

    Display a welcome message

    Else

    Ask the user to enter a user-id and password

    2) http://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/setting.php

    - If the user has not yet logged in

    o Ask the user to log in first

    - Else

    o Retrieve the value ofMfrom cookieo If the cookie does not exist, set M to 20

    o If the request method is POST

    Override Mwith the value retrieved from the request

    o IfM< 5, set M to 5

    o Update the value ofM in the cookie

    o Use a text field (with initial value set to M) to collect a new value ofMfrom the user

    http://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/login.phphttp://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/setting.phphttp://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/login.phphttp://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/setting.php
  • 8/6/2019 Asgn2 Spec

    2/3

    3) http://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/list.php

    - If the user has not yet logged in

    o Ask the user to log in first

    - Else

    o Retrieve the value ofMfrom cookie

    o If the cookie does not exist, set M to 20

    o Display M records on the selected page. (Default is page 1)

    All except the last page should contain exactly M records. Last page can contain

    less than M records.

    o Display at the bottoms some links or buttons to allow the user to access different pages

    4) http://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/logout.php

    - If a user is currently logged in

    o Log the user out

    - Redirect the client to login.php

    TOP Menu

    "login.php", "setting.php", and "list.php" share the same top menu, and the menu has the following

    behavior:

    - If a user is currently logged in

    o Display "Hi! " in the first menu itemo Display a link to "logout.php" in the 4th menu item

    - Else

    o Display a link to login.php in the first menu item

    o Do not show anything in the 4 th menu item

    Users

    The two sets of user name and password are:

    1) User name: john, password: 1232) User name: jane, password: 456

    http://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/list.phphttp://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/logout.phphttp://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/list.phphttp://www.cse.cuhk.edu.hk/~cjyuan/csc2720/asgn2/logout.php
  • 8/6/2019 Asgn2 Spec

    3/3

    Note s:

    1. Your web application does not need to look exactly the same as the sample web application.

    2. The file asgn2_inc.php contains

    a. getdata() a function that returns an array of 212 randomly generated records as an

    array of arrays. The following example illustrates how you can manipulate the returned

    value:

    b. login() a function that can be used to authenticate the user.

    3. If you make any assumptions in your implementation, please type them in a separate text file

    named "readme.txt".

    4. You may introduce additional files as you see fit. For examples, a CSS file, a PHP script that

    implements the top menu, etc.

    What to submit?

    Zip all your files, including "asgn2_inc.php", into "asgn2.zip and submit the file to Moodle.