Recommended: ADO beginner tutorial: ADO display The most common way to display data from a record set is to display the data in an HTML table. Show field names and field values We have a database named Northwind, and we want to display the data in the Customers table (remember to save this file with .asp as the extension): htmlbody%set conn=Server.CreateObject(
User login verification script, Chkpwd.asp
- <%
- '=========User login verification script========
- 'If the Passed object has not been defined, it is defined as false, indicating that it has not passed the verification
- IfIsEmpty(Session(Passed))Then
- Session(Passed)=false
- EndIf
- 'Session(Passed)=False, which means that the verification information passed from the form has not been passed yet.
- IfSession(Passed)=FalseThen
- UserName=Request.Form(UserName)
- UserPwd=Request.Form(UserPwd)
- IfUserName=Then
- Errmsg=Tip: Please enter your username and password
- Else
- '===================================================
- SetConn=Server.CreateObject(ADODB.Connection)
- Conn.Connectionstring=Driver={SQLServer};Server=192.168.1.3;UID=sa;PWD=;Database=zcmrs
- Conn.open
- '============================ Read user data from table log=========================
- 'Define RecordSet object
- Setrs=Server.CreateObject(ADODB.Recordset)
- 'Set ConnectionString of Connection object
- Setrs.ActiveConnection=Conn
- 'Set cursor type
- rs.CursorType=3
- 'Open record set
- rs.OpenSelectusername,passwordfromerpuserWhereusername='&UserName&'
- '===================================================
- Ifrs.EOFTThen
- Errmsg=Tip: The user does not exist or the password is wrong
- Else
- IfUserPwd<>rs.Fields(password)Then
- Errmsg=Tip: Login failed! Password error?
- Else'Login successfully
- Errmsg=
- Session(Passed)=True
- Session(UserName)=rs.Fields(username)
- 'Identify user permissions Session(UserID)=rs.Fields(UserID)
- EndIf
- EndIf
- EndIf
- EndIf
- 'After login failing, the login form will be drawn
- IfNotSession(Passed)=TrueThen
- %>
- <html>
- <head><title>Design Home_dwww.cn</title>
- <styletype=text/css>
- <!--
- .STYLE1{font-size:12px;font-weight:bold;margin-left:120px;outline:double}
- -->
- </style>
- <styletype=text/css>
- <!--
- .STYLE2{font-size:12px;font-weight:bold;outline:double;color:#FF3333}
- -->
- </style>
- </head>
- <bodyleftmargin=0topmargin=0marginheight=0marginwidth=0bgcolor=#000000>
- <divid=parentstyle=height:300;width:450;border-style:solid;border-color:#FFFFF;margin-top:80px;margin-left:25%;margin-right:25%;background-color:#FFFFF>
- <divid=denglustyle=font-size:12px;font-weight:bold;background-color:#0099FF;text-align:center;height:40px;><br>ERP system login</div>
- <formaction=<%=request.ServerVariables(path_info)%>method=postname=MyFormid=MyForm>
- <pclass=STYLE1>Username:<inputname=UserNametype=textid=UserNamesize=18maxlength=20>
- </p>
- <pclass=STYLE1> Password: <inputname=UserPwdtype=passwordid=UserPwdsize=18maxlength=20>
- </p>
- <palign=centerclass=STYLE2><%=Errmsg%></p>
- <p>
- <inputtype=submitalign=middlename=Submitvalue=Login system>
- <inputname=regetype=buttonalign=middleonClick=location='register.asp'id=regevalue=register user>
- </p>
- </form>
- </div>
- </body>
- </html>
- <%
- '<pclass=STYLE1>Verification code: <inputname=CheckCodetype=textid=CheckCodesize=6maxlength=4>
- '<IMGstyle=MARGIN-RIGHT:40pxalt=src=common/getcode.asp></p>
- response.End
- EndIf
- %>
Page to visit erp.asp
- <!--#includefile=chkpwd.asp-->
- <body>
- <divstyle='font-size:12px;font-weight:bold;border:1pxsolid#001;padding:4px;background:#FFCCFF;margin-top:0;'>Welcome to use the ERP query system, the current logged-in user is:
- <%
- IfSession(Passed)=TrueThen
- Response.Write(Session(UserName))
- EndIf
- %><ahref=logout.asp>Exit the system</a>
- </div>
- </body>
Every time you open erp.asp, you first execute Chkpwd.asp(), which can effectively prevent unauthorized users from accessing the specified web page.
Logout.asp system exit
- <body>
- <%
- Session(Passed)=false
- Session(UserName)=
- Response.Redirect(index.asp)
- %>
- </body>
Submit form using pictures
- <formname=form1method=postaction=>
- <tdalign=right><inputtype=imagemethod=submitname=submitsrc=image/loginin.gifwidth=70height=21alt=submit></td>
- </form>
Share: ADO beginner tutorial: ADO add records We can use SQL's INSERT INTO command to add records to tables in the database. Adding records to tables in database We want to add a new record to the Customers table in Northwind database. We first need to create a form that contains the fields we want to select data: htmlbodyform method=post action=dem