%
Response.Expires = -1000 'Makes the browser not cache this page
Response.Buffer = True 'Buffers the content so our Response.Redirect will work
%>
Login เข้าสู่ระบบ
<%
Dim Error_Msg
login = Request.Form("login")
If login = "login_again" Then
Session("UserLoggedIn") = ""
ShowLogin
Else
If Session("UserLoggedIn") = "true" Then
' change default.asp to the page you want the user to go to when they first log in
Response.Redirect("index.asp")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Else
If login = "true" Then
CheckLogin
Else
ShowLogin
End If
End If
End If
%>
<%
Sub ShowLogin
Response.Write(Error_Msg & " ")
%>
<%
End Sub
%>
<%
Sub AlreadyLoggedIn
%>
<%
End Sub
%>
<%
'declare variables
Sub CheckLogin
Dim Conn
Dim cStr
Dim sql
Dim RS
Dim username
Dim password
username = Request.Form("username")
password = Request.Form("password")
Set Conn = Server.CreateObject("ADODB.Connection")
cStr = "DRIVER={Microsoft Access Driver (*.mdb)};"
cStr = cStr & "DBQ=" & Server.MapPath("database/amnat.mdb") & ";"
Conn.Open(cStr)
sql = "select username from UserTable where username = '" & LCase(username) & "'"
sql = sql & " and password = '" & LCase(password) & "'"
Set RS = Conn.Execute(sql)
If RS.BOF And RS.EOF Then
Error_Msg = "
รหัสผ่านไม่ถูกต้อง ลองใหม่ครับ"
ShowLogin
Else
Session("UserLoggedIn") = "true"
' change default.asp to the page you want the user to go to when they first log in
Response.Redirect "index.asp"
End If
End Sub
%>