post.aspx
基本的東西在下載的列表文件就有,此處不再追加。我說(shuō)說(shuō)核心的東西:
第一行:
<%@ Page Language="vb" ValidateRequest="false" %>
ValidateRequest主要是檢驗(yàn)提交的數(shù)據(jù)中有html標(biāo)簽的話是不是要處理的bool值,這里false,就是可以提交html標(biāo)簽的意思+幾個(gè)驗(yàn)證控件+表單控件+驗(yàn)證碼組成了這個(gè)頁(yè)面的展示過(guò)程,其中驗(yàn)證碼圖片是:
<img src="inc/imgcheck.aspx" />
inc/imgcheck.aspx的內(nèi)容:
<%@ Page contenttype ="image/Jpeg" %> <%@ Import namespace ="CjjerBase" %> <script runat="server"> sub page_load() Img.CheckImg("imgcheck") end sub </script>
post.aspx的page_load():
sub post_but_click(s as object,e as eventargs) dim sessionstr as string ="imgcheck" if not postimgcheck(sessionstr,imgcheck.text) imgcheckinfo.isvalid = false else if isValid then post_mess.innerhtml ="謝謝您的留言" CinData.CinGeustData(server.HtmlEncode(user_name.text),server.HtmlEncode(book_title.text),ly.text)
response.redirect ("index.aspx") end if
end if end sub
先判斷數(shù)據(jù)驗(yàn)證合法不,合法的話檢驗(yàn)驗(yàn)證碼:
function postimgcheck(session_str as string ,session_value as string) as Boolean return session(session_str) = session_value end function
這些都合法的話添加都數(shù)據(jù)庫(kù):CinData::CinGeustData
Imports System Imports System.Web imports System.data imports System.data.oledb
namespace CJJERGUESTBOOK Public Class CinData Shared Sub CinGeustData(user_name as string ,book_title as string ,book_contents as string) dim conn as new Conn() dim sqlstr as string = "insert into [szd_book](user_name,book_title,book_contents,book_ip) values(@user_name,@book_title,@book_contents,@book_ip)" dim cmd as new oledbcommand cmd = conn.oledbcommand(sqlstr) cmd.parameters.add("@user_name", user_name) cmd.parameters.add("@book_title",book_title) cmd.parameters.add("@book_contents",book_contents) cmd.parameters.add("@book_ip", HttpContext.Current.Request.UserHostAddress) conn.executenonquery(cmd) End Sub End Class End namespace
就這點(diǎn)東西,演示圖片:
本節(jié)完。
程序打包下載:點(diǎn)擊下載
本教程未完,待續(xù),陸續(xù)更新
經(jīng)典論壇討論帖: http://www.95time.cn/bbs/NewsDetail.asp?id=2591191
出處:藍(lán)色理想
責(zé)任編輯:moby
上一頁(yè) 顯示留言,分頁(yè) 下一頁(yè)
◎進(jìn)入論壇網(wǎng)絡(luò)編程版塊參加討論
|