post.aspx
基本的东西在下载的列表文件就有,此处不再追加。我说说核心的东西:
第一行:
<%@ Page Language="vb" ValidateRequest="false" %>
ValidateRequest主要是检验提交的数据中有html标签的话是不是要处理的bool值,这里false,就是可以提交html标签的意思+几个验证控件+表单控件+验证码组成了这个页面的展示过程,其中验证码图片是:
<img src="inc/imgcheck.aspx" />
inc/imgcheck.aspx的内容:
<%@ 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
先判断数据验证合法不,合法的话检验验证码:
function postimgcheck(session_str as string ,session_value as string) as Boolean return session(session_str) = session_value end function
这些都合法的话添加都数据库: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
就这点东西,演示图片:
本节完。
程序打包下载:点击下载
本教程未完,待续,陆续更新
经典论坛讨论帖: http://www.blueidea.com/bbs/NewsDetail.asp?id=2591191
出处:蓝色理想
责任编辑:moby
上一页 显示留言,分页 下一页
◎进入论坛网络编程版块参加讨论
|