ASP:禁止站外提交表單

來源:互聯網
上載者:User
提交表單|提交表單

為了使asp盡量減少伺服器端的工作量,就應該多使用javascript,把所有提交欄位使用javascript或vbscript檢測後提交給伺服器,這樣伺服器就不必再作檢測,而在提交時可能會有人修改script從本地提交,這樣便存在安全提交的問題,所以應該要求從伺服器斷路徑提交,使其他地址提交提交無無效:
<%

server_v1=Cstr(Request.ServerVariables("HTTP_REFERER"))

server_v2=Cstr(Request.ServerVariables("SERVER_NAME"))

if mid(server_v1,8,len(server_v2))<>server_v2 then

response.write "<br><br><center><table border=1 cellpadding=20 bordercolor=black bgcolor=#EEEEEE width=450>"

response.write "<tr><td style='font:9pt Verdana'>" response.write "你提交的路徑有誤,禁止從網站外部提交資料請不要亂該參數!"

response.write "</td></tr></table></center>"

response.end

end if

%>



使用方法:

1. 將以上代碼另存新檔checkpath.asp

2. 在遇到表單提交的頁面引用此檢測代碼
<!--#include file="checkpath.asp"-->



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.