I recently made an ASP shopping website. I have some feelings.
1. Unlike net, there are not so many objects in it, which are basically process programming. The used objects include response, request, and server.
2. Use the logical code area <%>
3. Reference other pages or use the logic processing code <! -- # Include file = "XXXX. asp" -->
4. If, while, for and other statements are basically the if condition then execution statement end if
5. Create a database object using server. Createobject ("ADODB. recordset ")
6. Defining objects, like var, are weak types. Here we use the VB syntax dim to declare objects.
The following is the simple code of one of my pages, which can illustrate the above problems.
<! -- # Include file = "include/Conn. asp" --> <! -- # Include file = "include/function. asp" --> <! -- # Include file = "include/md5.asp" --> <% dim username, password, comeurlusername = Replace (TRIM (request. form ("username"), "'", "") Password = MD5 (replace (TRIM (request. form ("password"), "'", ""), 32) If trim (request. form ("comeurl") = "" Then comeurl = "member. ASP "else comeurl = trim (request. form ("comeurl") end ifif username = "" or password = "" Then response. write "<script language = 'javascript '> alert ('logon failed! Check your logon name and password! '); History. go (-1); </SCRIPT> "response. endend ifset rs = server. createobject ("ADODB. recordset ") rs. open "select * from [user] Where username = '" & username & "' and Password = '" & password & "'", Conn, 1, 3if not (RS. bof and Rs. EOF) then if Password = RS ("password") Then response. cookies ("timesshop") ("username") = trim (request. form ("username") RS ("lastvst") = now () RS ("loginnum") = RS ("loginnum") + 1 Rs. update Rs. close set Rs = nothing call loginok () else response. Write "<script language = 'javascript '> alert ('logon failed. Please check your login name and password! '); History. Go (-1); </SCRIPT> "End ifelse response. Write" <script language = 'javascript'> alert ('logon failed! Check your logon name and password! '); History. go (-1); </SCRIPT> "End ifsub loginok () response. write "<font size = 2> welcome <font color = Red size = 2>" & request. cookies ("timesshop") ("username") & "</font>. After two seconds, the page is automatically displayed! </Font> "response. Redirect comeurlend subconn. closeset conn = nothing %>
I have never learned ASP syntax. This time, I made adjustments on an original project, that is, I learned a little bit, and it took a little time to get it done, I also have a basic understanding of ASP. Because I often do net object programming, I am not used to it when I suddenly turn to process programming.