ASP Simple User Login

Source: Internet
Author: User

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, "<", "&lt;")
Temp=replace (temp, ">", "&gt;")
Temp=replace (temp, "'", "single quote")
Temp=replace (TEMP,CHR), "<br>"
Html_encode=replace (TEMP,CHR), "&nbsp;"
End Function

function encode_html (HTML)
Dim temp
Temp=replace (HTML, "&lt;", "<")
Temp=replace (temp, "&gt;", ">")
Temp=replace (temp, "single quote", "'")
Temp=replace (TEMP,CHR), "<br>"
Encode_html=replace (TEMP,CHR), "&nbsp;"
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
 
%>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.