var redirectstr = "login.htm"; var userField = "", passField = ""; /* Connect to the database. This is the only place in the application that a database connection is established, thus reducing delays for clients that do not need any services which require database access. */ if (!dbCheck()) { redirect("error.htm?error=dbfail"); } client.userID = request.userID; // First check for the special administrative login if ( isAdmin(client.userID, request.password) ) { client.valid = true; // admin has all privileges client.usertype = "admin"; redirectstr = "manage/manage.htm"; } else { // If not the administrator, check for a valid user. /* When calling isUser() to validate a user, we must pass not only the userID and password values, but also the names of the userID and password fields themselves, since the employer table and the seeker table can have different field names for the userID and password. In this example, the userID names are different. For the SEEKER table, the key is "userid". But for the EMPLOYER table, the user id field is called "empid". */ if (request.type == "seeker") { userField = "userID"; passField = "password"; } else { if (request.type == "employer") { userField = "empID"; passField = "password"; } } // END if-else client.valid = isUser(request.type, userField, request.userID, passField, request.password); if ( client.valid == "true" ) { //client.loginmsg = "You are already logged in for this session." if (request.type == "seeker") { client.usertype = request.type; redirectstr = "profile/seekhome.htm"; } else { if (request.type == "employer") { client.usertype = request.type; redirectstr = "profile/emphome.htm"; } } } else { client.valid = false; redirectstr = "login.htm?type=" + request.type + "&loginerr=true"; } // END if-else } // End top-level IF-ELSE. redirect(redirectstr);