ASP Simple User Login
<!--#include file= ". /inc/p_connect.asp "-->
<%
Dim uid,pwd
UID =html_encode (Request.Form ("UID"))
PWD =html_encode (Request.Form ("pwd"))
If uid = "Admin_videa" and pwd= "videa888" Then
Session ("Admin") =uid
Response.Redirect (".. /input.asp ")
Else
Response.Write ("<script>alert username and password incorrect!"); History.back ();</script> ")
Response.End ()
End If
%>
The following is a database connection function
<%
Dim Rs,conn
Sub Db_connect ()
Dpath = "\d_data\db2.mdb"
Set conn=server.createobject ("Adodb.connection")
Set Rs =server.createobject ("Adodb.recordset")
conn.connectionstring= "Provider=Microsoft.Jet.OLEDB.4.0;Data source=" &server.mappath (Dpath)
Conn.Open
End Sub
Sub Closedb ()
If IsObject (Rs) Then
If not (Rs are nothing) then
Rs.close
Set rs=nothing
End If
End If
If IsObject (Conn) Then
If not (Conn are nothing) then
Conn.close
Set conn=nothing
End If
End If
End Sub
' ********************************************************* Filter Not safe
function Html_encode (HTML)
Dim temp
Temp=replace (HTML, "<", "<")
Temp=replace (temp, ">", ">")
Temp=replace (temp, "'", "single quote")
Temp=replace (TEMP,CHR), "<br>"
Html_encode=replace (TEMP,CHR), " "
End Function
function encode_html (HTML)
Dim temp
Temp=replace (HTML, "<", "<")
Temp=replace (temp, ">", ">")
Temp=replace (temp, "single quote", "'")
Temp=replace (TEMP,CHR), "<br>"
Encode_html=replace (TEMP,CHR), " "
End Function
here is the exit login function
function Login ()
if session ("Admin") = "then
response.write (" <script>alert (' Sorry you haven't logged in! '); Location= '.. /login.asp ';</script> ')
response.end ()
end if
end function
%>