Handling Requests
The interactions in this eCourse require Javascript to be enabled.
Handling Requests
previous|next
The hr.php file contains all the PHP application Web page request and response handling logic. The logic uses the PHP session_start() function to store data as session state. Session state is used to track that the user has logged on and off, and for database error messages.
The request handling logic depends on an HTTP request parameter, called do, whose value is used to determine the next page to be displayed.
When a user first requests the hr.php page, the do HTTP parameter is not provided. Because the user has not logged in, the loggedin session parameter is not set. Therefore, the request handler calls the do_login() function to display the login page.
Here is the page-handling logic:
if (!isset($_REQUEST['do']) && !ui_islogged_in()) {
do_login();
}
else {
$doreq = isset($_REQUEST['do']) ? $_REQUEST['do'] : "showdept";
if ($doreq == "logout") {
do_logout();
}
elseif ($doreq == "showemp") {
construct_employees();
}
else {
construct_departments();
}
}
After the user has successfully logged in, an HTTP request without the do parameter causes the department information to be displayed. Otherwise, when the do HTTP parameter is:
logout, the user session is terminated and a logout page is displayed
showemp, the employees in the specified department are displayed. The department ID is obtained from an HTTP request parameter in the construct_employees() function.
Wyszukiwarka
Podobne podstrony:
les09 cre ui tmles09 disp?pt tmles09 create? logic tmles09 crectl logic tmles09 credb connect tmles09 get?pt tmles09 get emp tmles09 cregen query tmles09 disp emp tmles09 login page tmles09 logout page tmles09 create? conn prop tmles09 getstart tmpage$page&więcej podobnych podstron