Asp User Logon module instance code

Source: Internet
Author: User

 Asp User Logon module instance code:

User login verification script, Chkpwd. asp
Reference content is as follows:
<%
'======= User login verification script ======
'If Passed object has not been defined, define it as false, indicating that it has not Passed verification
If IsEmpty (Session ("Passed") Then
Session ("Passed") = false
End If
'Session ("Passed") = False, indicating that the verification has not Passed, the system starts to read the verification information from the form.
If Session ("Passed") = False Then
UserName = Request. Form ("UserName ")
UserPwd = Request. Form ("UserPwd ")
If UserName = "" Then
Errmsg = "prompt: Enter the user name and password"
Else
'============================== Connect to the database ========================= ===
Set Conn = Server. CreateObject ("ADODB. Connection ")
Conn. Connectionstring = "Driver = {SQL Server}; Server = 192.168.1.3; UID = sa; PWD =; Database = zcmrs"
Conn. open
'============================ Read user data from the table log ==================== ==========
'Define RecordSet object
Set rs = Server. CreateObject ("ADODB. Recordset ")
'Sets the ConnectionString of the Connection object.
Set rs. ActiveConnection = Conn
'Set the cursor type
Rs. CursorType = 3
'Open record set
Rs. Open "Select username, password from erpuser Where username = '" & UserName &"'"
'========================================================== ====
If rs. EOF Then
Errmsg = "prompt: the user does not exist or the password is incorrect"
Else
If UserPwd <> rs. Fields ("password") Then
Errmsg = "prompt: logon failed! Wrong Password? "
Else' logon successful
Errmsg = ""
Session ("Passed") = True
Session ("UserName") = rs. Fields ("username ")
'User permission Session ("UserID") = rs. Fields ("UserID ")
End If
End If
End If
End If
'The logon fails, the logon form is drawn.
If Not Session ("Passed") = True Then
%>
<Html>
<Head> <title> untitled document </title>
<Style type = "text/css">
<! --
. STYLE1 {font-size: 12px; font-weight: bold; margin-left: 120px; outline: double}
-->
</Style>
<Style type = "text/css">
<! --
. STYLE2 {font-size: 12px; font-weight: bold; outline: double; color: # FF3333}
-->
</Style>
</Head>
<Body leftmargin = 0 topmargin = 0 marginheight = "0" marginwidth = "0" bgcolor = "#000000">
<Div id = parent style = "height: 300; width: 450; border-style: solid; border-color: # FFFFFF; margin-top: 80px; margin-left: 25%; margin-right: 25%; background-color: # FFFFFF ">
<Div id = denglu style = "font-size: 12px; font-weight: bold; background-color: # 0099FF; text-align: center; height: 40px; "> <br> ERP system logon </div>
<Form action = "<% = request. ServerVariables (" path_info ") %>" method = "post" name = "MyForm" id = "MyForm">
<P class = "STYLE1"> User name: <input name = "UserName" type = "text" id = "UserName" size = "18" maxlength = "20">
</P>
<P class = "STYLE1"> password: <input name = "UserPwd" type = "password" id = "UserPwd" size = "18" maxlength = "20">
</P>
<P align = "center" class = "STYLE2"> <% = Errmsg %> </p>
<P>
<Input type = "submit" align = "middle" name = "Submit" value = "log on to the system">
<Input name = "rege" type = "button" align = "middle" onClick = "location = 'register. asp '" id = "rege" value = "registered user">
</P>
</Form>
</Div>
</Body>
</Html>
<%
'<P class = "STYLE1"> Verification Code: <input name = "CheckCode" type = "text" id = "CheckCode" size = "6" maxlength = "4">
' </p>
Response. End
End If
%>
Erp. asp
<Reference content is as follows:
<! -- # Include file = "chkpwd. asp" -->
<Body>
<Div style = 'font-size: 12px; font-weight: bold; border: 1px solid #001; padding: 4px; background: # FFCCFF; margin-top: 0; '> welcome to the ERP query system. The current logon user is:
<%
If Session ("Passed") = True Then
Response. Write (Session ("UserName "))
End If
%> <A href = "logout. asp"> log out of the system </a>
</Div>
</Body>
When you open erp. asp, Chkpwd. asp () is executed first, which effectively prevents unauthorized users from accessing the specified webpage.
Logout. asp system exited
<Body>
<%
Session ("Passed") = false
Session ("UserName") = ""
Response. Redirect ("index. asp ")
%>
</Body>
Use an image to submit a form
Reference content is as follows:
<Form name = "form1" method = "post" action = "">
<Td align = "right"> <input type = "image" method = "submit" name = "submit" src = "image/loginin.gif" width = "70" height =" 21 "alt =" submit "> </td>
</Form>

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.