Login

<% @ Language="JavaScript" %>

<%

var expDate = new Date();
expDate.
setMonth(expDate.getMonth() + 1); // set the Date for 1 Month from now

if (Request.ServerVariables("CONTENT_LENGTH") > 0) {

/********** SET UP CONNECTION & COMMAND OBJECTS **********/

     var adCmdText = 0x0001;

     var strDSN = "DRIVER={Microsoft Access Driver (*.mdb)};
                             DBQ=" + Server.
MapPath("calendar.mdb") + ";"

     var Cm = Server.CreateObject("ADODB.Command");

     Cm.ActiveConnection = strDSN;

     Cm.CommandText = "SELECT * FROM Users WHERE " +
                                       "Name='" + Request("Name") + "' AND " +
                                       "Password='" + Request("Password") + "' "

     Cm.CommandType = adCmdText;

     rs = Cm.Execute();

/********** END OF SET UP CONNECTION & COMMAND OBJECTS **********/

     if (rs.EOF) {
         
rst.Close();
         
rs = null;
          conn.
Close();
          conn = null;

          Session("Authenticated") = 0;
          Response.Redirect("login.asp");
     }
     else {
         
rst.Close();
         
rs = null;
          conn.
Close();
          conn = null;

          Session("Authenticated") = 1;
         
// set the Cookie expiration for 1 Month (from above)
         
// getVarDate() - is used when interacting with ActiveX or 
          // other objects that accept and return date values in VT_DATE format.
          // NOTE: An example when this is necessary is 
          // when using Access Database's Date Property
          Response.Cookies("Authenticated").Expires = expDate.getVarDate();
         
// set the Cookie "Authenticated" to "OK"
          Response.Cookies("Authenticated") = "OK"
          Response.Redirect(Session("sPage"));
     }
}
else {

%>

<HTML>
<HEAD><TITLE>
Calendar Administration</TITLE></HEAD>

<BODY>

<FORM ACTION="login.asp" METHOD="POST">
     Name: <INPUT TYPE="text" NAME="Name">
     Password: <INPUT TYPE="password" NAME="Password">
     <INPUT TYPE="SUBMIT" VALUE="Login Now">
</FORM>

</BODY>
</HTML>

<%

}

%>