My thoughts on ASP programming for the first time

Source: Internet
Author: User

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.

Related Article

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.