📄 asp读取通过表单发送的数据.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0047)http://www6.163.com/it/item/0,2186,5569,00.html -->
<!-- Vignette StoryServer 4 Wed Feb 27 05:20:54 2002 --><HTML><HEAD><TITLE>IT</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><!-- Vignette StoryServer 4 Fri Jun 30 09:33:27 2000 -->
<STYLE type=text/css>P {
FONT-FAMILY: 宋体; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt
}
DIV {
FONT-FAMILY: 宋体; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt
}
.p1 {
FONT-FAMILY: 宋体; FONT-SIZE: 9pt
}
.p2 {
FONT-FAMILY: 宋体; FONT-SIZE: 9pt; LINE-HEIGHT: 14pt
}
.p3 {
FONT-FAMILY: 宋体; FONT-SIZE: 14px
}
.p4 {
FONT-FAMILY: 宋体; FONT-SIZE: 14px; LINE-HEIGHT: 14pt
}
.p5 {
FONT-SIZE: 1pt
}
.headtable {
FONT-SIZE: 9pt
}
A:hover {
COLOR: red
}
A.t1:visited {
COLOR: red
}
</STYLE>
<META content="MSHTML 5.00.2919.6307" name=GENERATOR></HEAD>
<BODY aLink=#ff0000 bgColor=#ffffff link=#383098 text=#000000 topMargin=0
vLink=#336699><!-- Vignette StoryServer 4 Thu Nov 23 09:20:16 2000 -->
<TABLE border=0 cellPadding=0 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD class=headtable height=54 width=200><A href="http://www.163.com/"><IMG
border=0 height=54 src="IT4.files/163logo.gif" width=160></A> <BR> <A
class=headtable href="http://freemail.yeah.net/"><FONT
color=#ff0000>赶快申请8M永久免费电子邮箱</FONT></A><BR> <A class=headtable
href="http://bj4.netease.com/feedback/jobs.html">网易公司诚聘英才</A> </A></TD>
<TD align=right class=headtable width=540><FONT
color=#ff0000>>></FONT><A
href="http://www.163.com/index.html">返回首页</A> <A
href="http://news.163.com/index.html"><FONT color=#ff0000>焦点新闻</FONT></A>
<A href="http://mall.163.com/">网易商城</A> <A
href="http://bj.163.com/">网易社区</A> <A
href="http://www.yeah.net/index.html">搜索引擎</A> <A
href="http://freemail.yeah.net/">免费邮件</A> <A
href="http://auctions.163.com/">网上拍卖</A> <A
href="http://www.163.com/serve/">个人服务</A><BR><!--Here is ad beginning.--><IFRAME
frameBorder=0 height=60 marginHeight=0 marginWidth=0 scrolling=no
src="IT4.files/site=www.163.htm" width=468
BORDERCOLOR="#000000"><SCRIPT LANGUAGE="JavaScript1.1" SRC=http://adserver.163.com/js.ng/site=www.163.com&category=it&type=banner></SCRIPT><NOSCRIPT><A HREF=http://ad1.163.com/click.ng/Params.richmedia=yes&site=www.163.com&category=it&type=banner><IMG SRC=http://ad1.163.com/image.ng/Params.richmedia=yes&site=www.163.com&category=it&type=banner></A></NOSCRIPT></IFRAME><!--Here is ad end.--></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 height=10 width=740>
<TBODY>
<TR>
<TD><IMG border=0 height=0 src="IT4.files/dot.gif" width=0></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD width=70>
<TABLE border=0 cellPadding=0 cellSpacing=1 width="100%">
<TBODY>
<TR align=middle bgColor=#eeeeee>
<TD class=p1 height=20><A href="http://news.163.com/"><FONT
color=#000000>新闻</FONT></A></TD>
<TD class=p1><A href="http://sports.163.com/"><FONT
color=#000000>体育</FONT></A></TD></TR></TBODY></TABLE></TD>
<TD align=middle bgColor=#0036b2 class=p1 height=20 width=35><A
href="http://it.163.com/"><FONT color=#ffffff>电脑</FONT></A></TD>
<TD width=490>
<TABLE border=0 cellPadding=0 cellSpacing=1 width="100%">
<TBODY>
<TR align=middle bgColor=#eeeeee>
<TD class=p1 height=20><A href="http://game.163.com/"><FONT
color=#000000>游戏</FONT></A></TD>
<TD class=p1><A href="http://stock.163.com/"><FONT
color=#000000>财经</FONT></A></TD>
<TD class=p1><A href="http://house.163.com/"><FONT
color=#000000>房产</FONT></A></TD>
<TD class=p1><A href="http://culture.163.com/"><FONT
color=#000000>文化</FONT></A></TD>
<TD class=p1><A href="http://lady.163.com/"><FONT
color=#000000>女性</FONT></A></TD>
<TD class=p1><A href="http://movie.163.com/"><FONT
color=#000000>影视</FONT></A></TD>
<TD class=p1><A href="http://music.163.com/"><FONT
color=#000000>音乐</FONT></A></TD>
<TD class=p1><A href="http://life.163.com/"><FONT
color=#000000>生活</FONT></A></TD>
<TD class=p1><A href="http://travel.163.com/"><FONT
color=#000000>旅游</FONT></A></TD>
<TD class=p1><A href="http://science.163.com/"><FONT
color=#000000>科学</FONT></A></TD>
<TD class=p1><A href="http://health.163.com/"><FONT
color=#000000>健康</FONT></A></TD>
<TD class=p1><A href="http://jobs.163.com/"><FONT
color=#000000>职业</FONT></A></TD>
<TD class=p1><A href="http://education.163.com/"><FONT
color=#000000>教育</FONT></A></TD>
<TD class=p1><A href="http://spicy.163.com/"><FONT
color=#000000>新辣</FONT></A></TD></TR></TBODY></TABLE></TD><!--picture nav--><!--end picturenav-->
<TD align=right class=p1 vAlign=bottom width=155><FONT
color=#ff0000></FONT></TD></TR></TBODY></TABLE>
<TABLE border=0 cellPadding=0 cellSpacing=0 width=750>
<TBODY>
<TR>
<TD bgColor=#0036b2><SPACER height="1" type="block"></TR></TBODY></TABLE>
<TABLE>
<TBODY>
<TR>
<TD align=middle class=p1><A
href="http://all.163.com/it/pcdigest/index.htm">PCD个人网络手册</A> <A
href="http://www.163.com/it/item/0,2186,7448,00.html">Intel技术专题</A> <A
href="http://topsoft.163.com/software/">热门软件排行榜</A> <A
href="http://mobile.163.com/"><FONT color=red>手机站</FONT>全新改版</A> <A
href="http://all.163.com/it/popunet/study/10-1.htm">上网享受再教育</A> <A
href="http://gz.163.com/it2.htm">IT易:电脑频道广东版</A> <A
href="http://www.eshop.com.cn/">eNet导购专家</A> <A
href="http://all.163.com/it/hardbase/index.htm">硬件资料库</A> </TD></TR>
<TR>
<TD bgColor=#0036b2 class=p5 height=2 width=750>.</TD></TR>
<TR>
<TD height=4></TR></TBODY></TABLE>
<TABLE align=left border=0 cellPadding=0 cellSpacing=0 width=0>
<TBODY>
<TR>
<TD></TR></TBODY></TABLE>
<TABLE align=left border=0 cellPadding=4 cellSpacing=0 width=591>
<TBODY>
<TR>
<TD class=p2><A href="http://www6.163.com/it/index/0,2182,,00.html"><FONT
color=red>IT</FONT></A>>>><A
href="http://www6.163.com/it/category/0,2197,3,00.html"><FONT
color=red>软件时空</FONT></A>>>><A
href="http://www6.163.com/it/subcategory/0,2200,14,00.html"><FONT
color=red>编程指南</FONT></A>>>><FONT color=red>具体文章</FONT> </TD></TR>
<TR>
<TD align=middle class=p3 height=30><B>ASP:读取通过表单发送的数据</B>
<P align=center>(04/26/2000)</P></TD></TR>
<TR>
<TD class=p2 width=591>
<P class=p3>
<P> 学习ASP,最重要的就是要掌握ASP内置的六大对象。事实上,在上一讲中,我们已经了解了Response对象(是吗?有没有搞错!),及Response对象中最常用的Write方法、Redirect方法和Expires属性。看到对象、方法、属性、集合、事件这些概念(俺一个都不识!),如果以前没接触过,聪明的您就不要管这些概念了,知道怎么用就行了,我的观点是刚开始关键在于临摹。下面我们继续通过实例学习Request对象,为了加深理解,务请运行这些程序看看输出结果。<BR> 一、
使用Request.ServerVariables获取环境变量,这部分内容很简单,但获取的内容却很重要,如何获取?请看下例:<BR> <%@
Language=VBScript %><BR> <BR> <%
'wuf8.asp<BR> Response.Write“运行ASP文件的路径: " &_<BR>
Request.ServerVariables("Script_Name“) &
"<BR>"<BR> Response.Write“返回content的数据长度: " &_<BR>
Request.ServerVariables(“Content_Length") &“<BR>"<BR> Response.Write
“返回客户的IP地址: " &_<BR> Request.ServerVariables(“Remote_Addr") &
“<BR>"<BR> Response.Write “浏览器名: " &_<BR>
Request.ServerVariables(“HTTP_USER_AGENT") &
“<BR>"<BR> Response.Write“返回主页实际物理路径: " &_<BR>
Request.ServerVariables(“APPL_PHYSICAL_PATH") & “<BR>"<BR> %><BR>
</P>
<P>环境变量名 内容</P>
<P>result1 result2</P>
<P><BR> <BR> Now,你应该发现上一讲中的例程wuf2.asp原来是多么的easy!<BR> 注意:该程序的后面一部分HTML标记纯是为下面的例子作准备的,所以不要觉得奇怪。那么,还有哪些环境变量呢?运行下面的例子就知道了(本程序删除了部分代码,最好去我站点下载源程序便于理解)。<BR> <%@
Language=VBScript %><BR> <% 'wuf9.asp<BR> Option Explicit<BR> Dim
Sv<BR> %><BR> <BR> </P>
<P>环境变量名 结果</P>
<P>" "<BR> Response.Write Sv Response.Write
Request.ServerVariables(Sv)<BR> Response.Write “ Response.Write “
</P> <BR> 这里使用了For……Each循环,用来列举一个集合中的所有元素。如果后半部分看不懂,请对照wuf8.asp,再瞧瞧运行结果,仔细体会一下(什么态度?)。<BR> 二、
通过表单向服务器传送数据(也可这样理解,服务器端如何读取客户端发送的数据)<BR> 做过主页,应该知道很多主页通常都使用Form表单让用户输入数据,然后通过“submit(提交)”按钮发送数据。From表单中的“method”有两种主要方法:POST和GET,而“action”后一般都是指定一个.cgi、.pl或.asp文件,今天我们要学习的就是如果编写这个.asp文件。<BR> (一)
如果使用POST方法传送数据,则用Request.Form来读取数据。<BR> 先编辑如下一个wuf10.htm文件,供用户输入数据:<BR> <BR> <BR>
<FORM action='“wuf11.asp"' method='“post"'><BR> 姓名: <INPUT
name='“yourname"' type='“text"'> <BR><BR> 性别: <SELECT name='“gender"'>
<OPTION selected>男</OPTION> <OPTION>女</OPTION> </SELECT>
<BR><BR> 留言: <TEXTAREA name='“message"'>您好!<br> 注意多行文本的处理</TEXTAREA> <BR><BR>
爱好(按住Ctrl键可多选): <BR> <SELECT multiple name=hobby size='“4"'>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -