动态网页(使用a sp或jsp语言编写的网页)制作经验分享

上传人:小** 文档编号:88215922 上传时间:2019-04-21 格式:DOC 页数:16 大小:138.52KB
返回 下载 相关 举报
动态网页(使用a sp或jsp语言编写的网页)制作经验分享_第1页
第1页 / 共16页
动态网页(使用a sp或jsp语言编写的网页)制作经验分享_第2页
第2页 / 共16页
动态网页(使用a sp或jsp语言编写的网页)制作经验分享_第3页
第3页 / 共16页
动态网页(使用a sp或jsp语言编写的网页)制作经验分享_第4页
第4页 / 共16页
动态网页(使用a sp或jsp语言编写的网页)制作经验分享_第5页
第5页 / 共16页
点击查看更多>>
资源描述

《动态网页(使用a sp或jsp语言编写的网页)制作经验分享》由会员分享,可在线阅读,更多相关《动态网页(使用a sp或jsp语言编写的网页)制作经验分享(16页珍藏版)》请在金锄头文库上搜索。

1、所谓动态网页是针对静态网页而言的,即使用asp或jsp语言编写的网页,即网页URL的后缀不是.htm、.html、.shtml、.xml等静态网页的常见形式,而是以.asp、.jsp、.php、.perl、.cgi等形式为后缀,并且在动态网页网址中有一个标志性的符号“?”。ASP的工作原理(1)用户在地址栏中请求一个ASP程序,默认页面的扩展名是.asp。(2)浏览器从服务器上请求这个ASP程序,而不是像HTML一样直接处理一个自身的HTML程序,不需要在服务器上的运行。(3)ASP程序中的服务器端脚本开始运行ASP程序。(4)ASP程序连续的执行这个请求文件中的所有语句,然后生成一个HTML

2、文件。(5)页面信息发送到浏览器。在HTML语言里,标示一个标签是用尖括号,在ASP语言里其实没有什么不同,唯一的区别仅仅是使用来表示一个ASP的脚本语言的开始和结尾。ASP的代码可以出现在一个HTML页的任何位置。具体来讲,就是,一段ASP的代码可以出现来一个HTML的标签的前面,也可以出现在一个标签的里面。总之,ASP 和 HTML被紧紧地相互嵌套在了一起。 在使用数据库的时候,完全可以通过一段HTML的代码,创造一个模版,然后把数据库中一系列的的记录格式化,结构化的表现在一个页面里。并且对记录的操作,例如删除,添加也完全可以通过ASP的脚本来实现。也就是可以通过ASP的技术完成对数据库的

3、操作。 ASP可以让我们写很少的代码就可以实现对数据库数据的操作,另外,通过ASP技术可以让我们的静态HTML页面动态的反应数据库最新的数据信息。VBScript 是ASP脚本的默认语言。如果你想使用其他的语言,那么你需要去说明它。,其中,Scripting Language就是要设定的脚本语言。应注意的是:上述语句形式中,必须在“ % ”之后加入一空格。什么是脚本语言脚本语言是介于 HTML 、 Java、C+ 和 Visual Basic 的语言之间的语言。HTML 通常用于格式化文本和链接网页,编程语言通常用于向计算机发送一系列复杂指令。脚本语言也可用来向计算机发送指令,但它们的语法和规

4、则没有可编译的编程语言那样严格和复杂。脚本语言主要用于格式化文本和使用以编程语言编写的已编译好的组件。%response.buffer=trueResponse.Expires=0usercookies=Request.Cookies(usercookies)if not session(password) thenif usercookies 0 thenname=Request.Cookies(username)password=Request.Cookies(password)sql=select * from admin where id=1set rs8=conn.execute(s

5、ql)if not(rs8.bof and rs8.eof) thenif password=rs8(userpass) and name=rs8(username) then session(user)=name session(password)=wpasswordend ifend ifend ifend ifSet rs9 = Server.CreateObject(ADODB.Recordset)sql9 =SELECT * From about Order By id DESCRS9.open sql9,Conn,3,3mypagesize=cint(rs9(num) 每页显示留言

6、数badnicks=rs9(badnicks)badwords=rs9(badwords)Set rs = Server.CreateObject(ADODB.Recordset)sql = Select * FROM guestbook Order By dateandtime Descrs.open sql,conn,1,1IF not IsNumeric(Request(page) Or IsEmpty(Request(page) Thenpage=1ElsePage=Int(Abs(Request(page)End ifrs.pagesize = mypagesizetotal = r

7、s.RecordCountrs.absolutepage = pageif request(test)=insert then校验码判断开始If Request(checkcode)= ThenMessageBox 别椤着,请返回输入验证码啊 response.endElseif Session(CheckCode)= thenMessageBox 请返回后请刷新登录页面后重新输入正确的信息 response.endElseIf Cstr(Session(CheckCode)Cstr(Trim(Request(checkcode) ThenMessageBox 您输入的验证码和系统产生的不一致

8、,请重新输入。 response.endEnd if校验码判断结束防止垃圾留言功能开始dim ComeUrl,cUrlComeUrl=lcase(trim(request.ServerVariables(HTTP_REFERER)if ComeUrl= thenMessageBox 错误信息:对不起,为了系统安全,不允许直接输入地址访问本页面。response.endelsecUrl=trim(http:/ & Request.ServerVariables(SERVER_NAME)if mid(ComeUrl,len(cUrl)+1,1)=: thencUrl=cUrl & : & Requ

9、est.ServerVariables(SERVER_PORT)end ifcUrl=lcase(cUrl & request.ServerVariables(SCRIPT_NAME)if lcase(left(ComeUrl,instrrev(ComeUrl,/)lcase(left(cUrl,instrrev(cUrl,/) thenMessageBox 错误信息:留言本防垃圾留言功能已经打开,禁止从外部链接地址提交留言。response.endend ifend if防止垃圾留言功能结束txtname=left(request(txtname),30)txtemail=left(requ

10、est(txtemail),30)txthomepage=left(request(txthomepage),50)txtoicq=left(request(txtoicq),10)if request.form(xxx)= thenpic=images/1.gifelsepic=request.form(xxx)end iftxtcome=left(request(txtcome),20)sex=request(sex)txtcontent=left(request(txtcontent),500)设置灌水限制posttime=60if cint(posttime)0 thenif not

11、isnull(session(posttime) or cint(posttime)0 thenif DateDiff(s,session(posttime),Now()cint(posttime) thenMessageBox 错误信息:留言本防灌水功能已经打开,限制&posttime&秒内不能重复留言。response.endend ifend ifend ifif txtemail and IsValidEmail(txtemail)=false thenMessageBox 错误信息:邮件地址填写出错:请确认你的邮件地址。 response.endend ifif txtname= t

12、henMessageBox 别椤着,输入内容啊 response.endend ifif txtcontent= thenMessageBox 错误信息:请填入你的名字! response.endend ifif txtemail= then txtemail=不告诉你!if txtoicq= then txtoicq=打死我也不说!if txtcome= then txtcome=保密!if txthomepage= or txthomepage=http:/ then txthomepage=还没有呢!function MessageBox(strOutput)response.write

13、 & VbCRlf response.write alert( & strOutput & ); & VbCrlf response.write history.go(-1); & vbCrlf response.write & VbCRLF response.endend functionfunction IsValidEmail(email) dim names, name, i, c IsValidEmail = true names = Split(email, ) if UBound(names) 1 then IsValidEmail = false exit function end if for each name in names if Len(name) = 0 then IsValidEmail = false exit function end if for i = 1 to Len(name) c = Lcase(Mid(name, i, 1) if InStr(abcdefghijklmnopqrstuvwxyz_-., c) = 0 and not IsNumeric(c) then IsValidEmail = false

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 商业/管理/HR > 管理学资料

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号