Application function in ASP application

Source: Internet
Author: User
1, often write some systems, then generally from the login program to start, every system to write a login, good trouble.
Simply do a login verification function, for me, most of the situation can be competent:
<%
Function chk_regist (Requestname,requestpwd,tablename,namefield,pwdfield,reurl)
Dim cn_name,cn_pwd
Cn_name=trim (Request.Form ("&requestname&"))
Cn_pwd=trim (Request.Form ("&requestpwd&"))
If Cn_name= "" or cn_pwd= "" Then
Response. Write ("<script language=javascript>alert" "Please complete the account password, thank you for your cooperation." ""); History.go ( -1) </script> ")
End If
Set rs = Server.CreateObject ("ADODB.") Recordset ")
sql = "SELECT * from" &tablename& "where" &namefield& "= '" &cn_name& "'"
Rs.Open sql,conn,1,1
If Rs.eof Then
Response. Write ("<script Language=javascript>alert" ("") does not have this member ID, please confirm that has not been applied. ""); History.go ( -1) </script> ")
Else
If RS ("&pwdfield&") =cn_pwd Then
Session ("Cn_name") =rs ("&namefield&")
Response. Redirect (Reurl)
Else
Response. Write ("<script Language=javascript>alert" "Reminder that your account number and password are not consistent. Pay attention to numbers and capitalization. ""); History.go ( -1) </script> ")
End If
End If
Rs.close
Set rs = Nothing
End Function
%>

Parameter description:
Chk_regist (Requestname,requestpwd,tablename,namefield,pwdfield,reurl)
Requestname an input control name that accepts an input name in an HTML page
Requestpwd the name of an input control that accepts a password in an HTML page
TableName The name of the table that holds the registration information in the database
Namefield the name of the field that holds the username for the information table
Pwdfield the name of the field that holds the user's password in the information table
Reurl the page to which the login is correct
Examples of references are as follows:
<%
Call Chk_regist ("B_name", "B_pwd", "Cn_admin", "Cn_name", "Cn_pwd", "admin.asp")

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.