/* Check to make sure we are connected to the database before
allowing access to the home page. If not connected, go connect
and initialize; otherwise, welcome the user.\
*/
if(!database.connected())
redirect("init.htm");
if (request.ssn == "new") {
redirect("newusr.htm");
}
cursor = database.cursor("select ssn, pin, name from employee where ssn = " + request.ssn);
cursor.next()
if (request.ssn == cursor.ssn && request.pin != cursor.pin)
{
// User is a member, but doesn't remember pin.
if (client.loginNo > 2) {
redirect("hr.htm");
} else {
client.loginNo++;
redirect("login.htm");
}
}
else if (request.ssn == cursor.ssn && request.pin == cursor.pin)
{
// User is already a member.
client.ssn = request.ssn
client.pin = request.pin;
redirect("mainmenu.htm");
} else {
// User is not a member.
client.ssn = request.ssn;
client.pin = request.pin;
redirect("newusr.htm");
}