This lab assignment involves implemementing some simple session management using PHP.
What you must do is write a PHP script that can do the following: 1) generates a form for user input and 2) generates a "Welcome" page based on the user's input.
If a user goes to your page for the first time since she opened her browser, you need to display the form page. This page must allow the user to enter her name and 3 favorite URLs. Once entered, the user should be directed to the "Welcome" page. This page must acknowledge the user by name with a message like "Welcome Kai!" and provide the entered urls as usable links to take the user elsewhere.
If the user is to use any other links or leave the page for any other reason and later return, the page should have the user's context saved such that the "Welcome" page and not the "Form" page should be displayed. Additionally, the welcome page must have a mechanism to clear the context for that particular user and return to the "Form" page for new user information collection. You could possibly display a link saying something like "If not Kai click here..." which targets your PHP page with a command to reset.
In this lab assignment, you are encouraged (though not required) to write all code in one PHP file. Here is the suggestion of one approach to organize all code in one PHP file. You may create a file that will take different actions based on the URL that triggered the file by adding a parameter to the URL links in your code and checking the value of the URL parameter in the PHP script. URL parameters are stored in the $_GET array. For example, if a user clicks the link <a href="lab3.php?action=killSession"/> in lab3.php, this link will re-load the lab3.php file. By checking the value in the $_GET array, your script will know that the URL requested is different from the default URL a user might type in their web browser http://people.ucsc.edu/~someUser/lab3.php.
For submission please email pankai [at] cse [dot] ucsc [dot] edu your php script and a URL to the script on a working webserver such as your user directory on the people.ucsc.edu servers.
Last modified: