初次嘗試asp編程感想

來源:互聯網
上載者:User

最近做了一個asp的購物網站,有點感想,分享下

1.和net不一樣的是裡面沒有那麼多個物件,基本上都是過程編程,利用到的對象有response,request,server

2.邏輯代碼地區使用<%%>負責

3.引用其他頁面或者邏輯處理代碼使用<!--#include file="xxxx.asp" -->

4.if,while,for等語句基本上都是if 條件 then 執行語句 end if

5.建立資料庫物件使用server.CreateObject("adodb.recordset")

6.定義對象類似var一樣,都是弱類型的,這裡採用vb文法dim來申明對象

下面是我的一個頁面的簡單代碼,可以說明上面這些問題

<!--#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('登入失敗!請檢查您的登入名稱和密碼!');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('登入失敗,請檢查您的登入名稱和密碼!');history.go(-1);</script>"    end ifelse    response.write "<script LANGUAGE='javascript'>alert('登入失敗!請檢查您的登入名稱和密碼!');history.go(-1);</script>"end ifsub loginok()response.Write "<font size=2>歡迎  <font color=red size=2>"&request.Cookies("timesshop")("username")&"</font>,光臨兩秒種後將自動跳轉到相應頁!</font>"response.redirect comeurlend subconn.closeset conn = nothing%>

一直都沒學過asp的文法,這次也是在原來的一個項目上做調整,也就是看一點學一點,花了一點時間算是搞定了,也對asp有了基本的瞭解。由於經常都是做net方面的對象編程,突然轉到過程編程上來還真有點不習慣

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.