WEB大作业

  • 格式:doc
  • 大小:780.50 KB
  • 文档页数:12

学号 07500225Web程序设计与应用实验报告电影《风声》问卷调查系统学生姓名王涵笛专业、班级07电子商务二班指导教师张慧成绩电子与信息工程系2009 年 11 月 5 日天津城市建设学院设计性实验任务书管理工程系电子商务专业二班姓名王涵笛学号07500225课程名称:Web程序设计与应用设计题目:请设计一个简单的表单与数据库连接并进行简单的数据处理的ASP程序完成期限:自2009 年10 月21 日至2009 年10 月28 日设计依据、要求及主要内容(可另加附页):1、设计依据:本实验是以教材《Web程序设计与应用》一书为依据, 掌握Asp相关对象及Access数据库的使用。

2、设计要求:假设有数据库diaocha2.mdb,数据表为diaocha,表中字段question1,question2,question3,question4,question5,question6。

设计一个程序,设置了调查页面,上有6个问题,然后调查后,往数据库里添加调查记录。

实现了数据库的增加、修改、删除等操作。

指导教师:张慧一、实验目的设计一个表单,与Access数据库作连接,并具有对数据库中的数据进行查询、添加、编辑、删除等的功能。

二、实验内容假设有数据库diaocha2.mdb,数据表为diaocha,表中字段question1,question2,question3,question4,question5,question6。

设计一个程序,设置了调查页面,上有6个问题,然后调查后,往数据库里添加调查记录。

实现了数据库的增加、修改、删除等操作。

三、实验思想利用ASP进行数据库的程序设计,先设计好数据库,再建立获取信息的表单,再将两者连接起来,并完成查询、添加、编辑、删除的功能。

四、实验结果数据库:问卷调查页面(添加功能):调查结果显示页面:修改功能:删除功能:代码:add代码<html><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" c /><title>电影《风声》影片调查</title><style type="text/css"><!--.STYLE1 {font-family: "方正行楷简体";font-size: xx-large;color: #FF0000;}body {background-image:url(tupian/nt_D520100gyrb_20090609_1-8-B8_resbrief.jpg);}.STYLE6 {font-family: "宋体"; color: #003300; font-weight: bold; }.STYLE9 {font-family: "黑体"; color: #003300; font-weight: bold; } .STYLE10 {color: #66FF00}--></style></head><body><form name="form1" method="post" action="add_new.asp"><p align="center" class="STYLE1 STYLE10">电影《风声》影片调查</p> <table width="663" height="553" border="1" align="center" bordercolor="#FFFFFF" bgcolor="#FF99FF"><tr><td width="321"><div align="center" class="STYLE9">问题</div></td><td width="326"><div align="center" class="STYLE9">选项</div></td></tr><tr><td colspan="2"><span class="STYLE6">总体评价</span></td></tr><tr><td><span class="STYLE6">1、您在观看完电影本影片对本影片的总体印象是?</span></td><td><input type="radio" name="question1" value=" 一般">一般<input type="radio" name="question1" value=" 很好">很好</td></tr><tr><td><span class="STYLE6">2、本影片中那个演员给你留下了深刻印象?(可多选)</span></td><td><input type="checkbox" name="question2" value=" 王志文 "> 王志文<input type="checkbox" name="question2" value=" 周迅">周迅<input type="checkbox" name="question2" value=" 张涵予">张涵予<input type="checkbox" name="question2" value=" 苏有朋">苏有朋 </td></tr><tr><td><span class="STYLE6">3、您通过什么途径知道的本影片?</span></td><td><input type="radio" name="question3" value=" 朋友推荐"> 朋友推荐<input type="radio" name="question3" value=" 影片的宣传"> 影片的宣传<input type="radio" name="question3" value=" 其他"> 其他 </td></tr><tr><td><span class="STYLE6">4、您在哪观看的本影片?</span></td> <td><input type="checkbox" name="question4" value=" 电影院"> 电影院<input type="checkbox" name="question4" value=" 家里"> 家里<input type="checkbox" name="question4" value=" 其他"> 其他 </td></tr><tr><td><span class="STYLE6">5、您在电影结未结束时是否已经猜出“老鬼”是谁?</span></td><td><input type="radio" name="question5" value=" 是的,早就猜出来了 "> 是的,早就猜出来了<input type="radio" name="question5" value=" 没有,最后才知道">没有,最后才知道 </td></tr><tr><td><span class="STYLE6">6、您在观看完影片后印象最深或最喜欢的一句台词是?</span></td><td> <textarea name="question6" cols="25"></textarea> </td></tr><label> </label><div align="center"><input type="submit" name="Submit" value="提交"><input type="reset" name="Submit2" value="重置"></div><div align="center"></div></form></td><hr size=8 color="blue"></tr></table><p>&nbsp;</p><p align="center">&nbsp;</p></body></html>add_new代码:<!--#include file="conn.asp"--><%question1=request.form("question1")question2=request.form("question2")question3=request.form("question3")question4=request.form("question4")question5=request.form("question5")question6=request.form("question6")exec="insert into diaocha (question1,question2,question3,question4,question5,question6)values('"+question1+"','"+question2+"','"+question3+"','"+question4+" ','"+question5+"','"+question6+"')"conn.execute execconn.closeset conn=nothingresponse.redirect "index.asp"%>conn代码:<%Set conn = Server.CreateObject("ADODB.Connection")rs="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("diaocha1/diaocha2.mdb")conn.Open rsset rs=server.CreateObject("adodb.recordset")%>del代码<!--#include file="conn.asp"--><%exec="delete * from diaocha where id="&request.querystring("id") conn.execute execconn.closeset conn=nothingresponse.redirect "index.asp"%>index代码<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="/1999/xhtml"><center><head><MARQUEE bgcolor="#FFFF00" width=80% behavior="alternate" loop=-1> <font size="6" color="#0000CC">风声之后,再无传奇!</font></MARQUEE><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title> 《风声》问卷</title></head><body text="red"><h2 align="center"> 《风声》问卷列表</h2><!--#include file="conn.asp" --><%exec="select * from diaocha order by id asc "set rs=server.createobject("adodb.recordset")rs.open exec,conn,1,3%><table width="628" height="46" border="1" align="center" cellpadquestion="1" cellspacing="0"><%if rs.eof and rs.bof thenresponse.write(" 《风声》问卷信息")elsedo while not rs.eof%><tr><td width="66" height="22" ><font color="#000000">id</font></td> <td width="66" ><font color="#000000">question1</font></td><td width="66" ><font color="#000000">question2</font></td><td width="66" ><font color="#000000">question3</font></td><td width="66" ><font color="#000000">question4</font></td><td width="66" ><font color="#000000">question5</font></td><td width="66" ><font color="#000000">question6</font></td><td width="92"><font color="#000000">修改</font></td><td width="60" ><font color="#000000">删除</font></td></tr><tr><td height="22" ><%=rs("id")%></td><td ><%=rs("question1")%></td><td ><%=rs("question2")%></td><td ><%=rs("question3")%></td><td ><%=rs("question4")%></td><td ><%=rs("question5")%></td><td ><%=rs("question6")%></td><td><a href="modify.asp?id=<%=rs("id")%>" target="_self">修改</a></td><td ><a href="del.asp?id=<%=rs("id")%>">删除</a></td></tr><%rs.movenextloopend if%></table><%rs.closeset rs=nothingconn.closeset conn=nothing%><td><div align="right"><a href="add.asp">添加</a></div></td></body><hr size=8 color="blue"><h2 align="center">风声之后,再无传奇!</h2></center></html>modify代码<!--#include file="conn.asp"--><%exec="select * from diaocha where id="&request.querystring("id") set rs=server.createobject("adodb.recordset")rs.open exec,conn,1,3%><form name="form1" method="post" action="modifysave.asp"><table width="748" border="0" cellspacing="0" cellpadquestion="0"> <tr><td>question1</td><td>question2</td><td>question3</td><td>question4</td><td>question5</td><td>question6</td></tr><tr><td><input type="text" name="question1" value="<%=rs("question1")%>"> </td><td><input type="text" name="question2" value="<%=rs("question2")%>"> </td><td><input type="text" name="question3" value="<%=rs("question3")%>"> </td><td><input type="text" name="question4" value="<%=rs("question4")%>"> </td><td><input type="text" name="question5" value="<%=rs("question5")%>"> </td><td><input type="text" name="question6" value="<%=rs("question6")%>"> </td><td><input type="submit" name="Submit" value="提交"><input type="hidden" name="id" value="<%=request.querystring("id")%>"></td></tr></table></form><%rs.closeset rs=nothingconn.closeset conn=nothing%>modifysave代码<!--#include file="conn.asp"--><%exec="select * from diaocha where id="&request.form("id")set rs=server.createobject("adodb.recordset")rs.open exec,conn,1,3%><%rs("question1")=request.form("question1")rs("question2")=request.form("question2")rs("question3")=request.form("question3")rs("question4")=request.form("question4")rs("question5")=request.form("question5")rs("question6")=request.form("question6")rs.updaters.closeset rs=nothingconn.closeset conn=nothingresponse.redirect"index.asp"%>五、实验心得通过对这章的学习,了解获取用户信息之后的后台数据库处理的一些基本知识,对以后的学习和工作有很大的帮助。