Every time I write the system, I need to log in to the program, which makes it extremely troublesome. In fact, we can make several commonly used functional modules into login verification functions. So what are the several commonly used functional modules in ASP? Now let’s take a look at the introduction of commonly used functional modules of ASP.
[code]
<%
Function chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl)dim cn_name,cn_pwdcn_name=trim(request.form(""&requestname&""))cn_pwd=trim(request.form(""&requestpwd&""))if cn_name="" or cn_pwd="" thenresponse.Write("<script language=javascript>alert(""Please fill in the account password in full, thank you for your cooperation."");history.go(-1)</script>")end ifSet rs = Server.CreateObject ("ADODB.Recordset")sql = "Select * from "&tablename&" where "&namefield&"=''"&cn_name&"''"rs.open sql,conn,1,1if rs.eof thenresponse.Write("<script language=javascript>alert(""No this member ID, please confirm whether you have been applied."");history.go(-1)</script>")elseif rs(""&pwdfield&"")=cn_pwd then session("cn_name")=rs(""&namefield&"")response.Redirect(reurl)elseresponse.Write("<script language=javascript>alert(""Reminder, your account and password do not match. Pay attention to numbers and uppercase and lowercase."");history.go(-1)</script>")end ifend ifrs.close Set rs = NothingEnd Function%>
[code]
Parameter description:
chk_regist(requestname,requestpwd,tablename,namefield,pwdfield,reurl)
requestname is the INPUT control name that accepts the name entered in the HTML page.
requestpwd is the name of the INPUT control that accepts the password entered in the HTML page.
tablename is the name of the table that saves registration information in the database
namefield is the field name that stores the user name in this information table
pwdfield is the field name of the user's password in this information table
reurl is the page that jumps after logging in correctly
The citation examples are as follows:
<%call chk_regist("b_name","b_pwd","cn_admin","cn_name","cn_pwd","admin.asp")%>
2. It is often possible to judge the current state of something, usually a field (numeric type, default value is 0)
The effect of state switching is achieved by modifying the value of this field. So, I made another function to make it easy for myself.
<%Function pvouch(tablename,fildname,autoidname,indexid)dim filtervalueSet rs = Server.CreateObject ("ADODB.Recordset")sql = "Select * from "&tablename&" where "&autidname&"="&indexidrs.Open sql,conn,2,3fildvalue=rs(""&fildname&"")if filtervalue=0 thenfildvalue=1elsefildvalue=0end ifrs(""&fildname&"")=fildvaluers.updaters.close Set rs = NothingEnd Function%>
Parameter description:
pvouch(tablename,fildname,autoidname,indexid)
tablename table name in the database where the thing is located
filmname This thing is used to indicate the field name of the state (the field type is numerical)
autoidname's automatic numbering name in this table
indexid is used to modify the corresponding automatic numbered value of the state
The citation examples are as follows:
<%dowhat=request.QueryString("dowhat")p_id=cint(request.QueryString("p_id"))if dowhat="tj" and p_id<>"" thencall pvouch("cn_products","p_vouch","p_id",p_id)end if%><%if rs("p_vouch")=0 then%>>Recommended<%else%>>Cancel recommendation<%end if%>
3. Write websites for many small and medium-sized enterprises. Generally, product display is a big project, so the pages made are different.
Either a few are arranged horizontally, or a few are arranged vertically, or even a whole station has to toss and turns several times, which is very troublesome and tiring.
Just write a function to relieve it, so it became the following
<%function showpros(tablename,topnum,fildname,loopnum,typepenum)Set rs = Server.CreateObject ("ADODB.Recordset")sql = "Select top "&topnum&" * from "&tablenames.Open sql,conn,1,1if rs.eof and rs.bof thenresponse.Write("No record at the moment")elseresponse.Write("")for i=1 to rs.recordcountif (i mod loopnum=1) thenresponse.write" "end ifselect case typenumcase "1" response.Write(" ")response.Write(rs(""&fildname&""))response.Write("""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" ")response.Write(" ")end selectif (i mod loopnum=0) thenresponse.write" "end ifrs.movenextnextresponse.Write(" ")end ifrs.close Set rs = Nothingend function%>
Parameter description: showpros(tablename, topnum, filtername, loopnum, typepenum)
Which Pro chooses the type of product
topnum means how many records are extracted
Fildname represents the field displayed by debugging. This parameter can be omitted when applying it in detail and used directly within the function
loopnum represents the number of records per row of the displayed loop
Typenum represents the method of circular display: Currently there are two categories, horizontally parallel and vertically parallel display different records of the same data record row.
The citation examples are as follows:
<%if request.form("submit")<>"" thentopnum=request.form("topnum")loopnum=request.form("loopnum")typenum=request.form("typenum")elsetopnum=8loopnum=2typenum=1end if%><%call showpros("cn_products",topnum,"p_name",loopnum,typenum)%>
The above is the entire content of this article. I hope the content of this article will be of some help to your study or work. If you have any questions, you can leave a message to communicate. Thank you for your support from the new technology channel right or wrong!