Several functional modules used in ASP _ Application techniques
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:
[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 password complete, 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" ("") is not a member ID, please confirm that there is no application. ""); History.go ( -1) </script> ") Elseif rs (" "&pwdfield&") =cn_pwd then session ("Cn_ Name ") =rs (" &namefield& ") response. Redirect (Reurl) elseresponse. Write ("<script language=javascript>alert" reminds you that your account number and password are not consistent. Pay attention to numbers and capitalization. ""); History.go ( -1) </script> ") end ifend ifrs.close set rs = nothingend function%>
[Code]
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")%>
2, it is often possible to make a judgment of the current state of a thing, generally do a field (numeric type, default value is 0)
The effect of state switching is achieved by modifying the field value. So, I did a function to make myself relaxed.
<%function Pvouch (Tablename,fildname,autoidname,indexid) Dim Fildvalueset rs = Server.CreateObject ("ADODB.") Recordset ") sql =" SELECT * from "&tablename&" where "&autoidname&" = "&indexidrs. Open sql,conn,2,3fildvalue=rs ("&fildname&") if fildvalue=0 thenfildvalue=1elsefildvalue=0end IFRS ("" & fildname& "") =fildvaluers.updaters.close Set rs = NothingEnd function%>
TableName The name of the table in the database where the object resides
Fildname the name of the field to indicate the state (field type is a numeric type)
Autoidname name of the automatic number in the table
IndexID value of the corresponding AutoNumber used to modify the state
Examples of references 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%>> recommendation <%else%>> Cancel recommendation <%end if%>
3, for many small and medium-sized enterprises to write sites, general product display is a big project, then made a page is also different.
or the horizontal to a few, or vertical row to several, or even the whole station to toss and turn a few times, trouble is very tired.
Simply write a function to alleviate, so it became the following
<%function showpros (Tablename,topnum,fildname,loopnum,typenum) set rs = server.createobject ("ADODB.") Recordset ") sql = " select top "&topnum&" * from "&tablenamers. Open sql,conn,1,1if rs.eof and rs.bof thenresponse. Write ("not currently logged") 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 (Mode 1 &i& record) "Mode 1" here replaces the value response displayed as the remaining fields. Write (" ") ' If there are more fields, continue to add a new table row to display response. Write (" ") case "2" response. Write (" ") response. Write (RS ("&fildname&")) response. Write (" ") response. Write (" ") response. Write ("Mode 2" &i& "record") 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,fildname,loopnum,typenum)
Whichpro to choose what type of product
Topnum indicates how many records are extracted
Fildname represents the fields that are displayed for debugging, which can be omitted when applied, and used directly within the function.
Loopnum represents the number of record bars per row displayed by the loop
Typenum represents the method of looping display: currently divided into two categories, horizontal side-by-side, vertically parallel display of the same data record rows of different records
Examples of references 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 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