cookies应用
我没选中任何爱好提交时,为什么浏览器把全部爱好都列出来了呀?实在找不出错误来了
5-11.asp内容:
<%
username=request.Form("name")
password=request.Form("password")
i=1
for counter=1 to request.Form("fancy").count
redim preserve userfancys(i)
userfancys(i-1)=request.Form("fancy")(counter)
i=i+1
next
response.write(request.form("fancy").count&"<p>")
response.Write i
%>
<%
response.Cookies("username")=username
response.Cookies("username").expires=#december 31,2007#
response.Cookies("password")=password
response.Cookies("password").expires=#december 31,2007#
for counter=1 to i-1
c="prefs"&cstr(counter)
response.Cookies("fancys")(c)=userfancys(counter-1)
next
response.Cookies("fancys").expires=#december 31,2007#
%>
用户名为:<%response.Write request.cookies("username")%><br>
密码为:<%=request.cookies("password")%><br>
<%for each key in request.cookies("fancys")
response.Write(key)&"个爱好:"
response.Write (request.cookies("fancys")(key)&"<p>")
next
%>
</html>
5-11.html内容:
<body>
<form name="form1" action="5-11.asp" method="post">
用户名:<input type="text" name="name" size="10" /><br />
密 码:<input type="text" name="password" size="6" /><br />
<hr color="#00FF00"/>
你的爱好:<br>
<input type="checkbox" name="fancy" value="sing" />唱歌
<input type="checkbox" name="fancy" value="dance" />跳舞
<input type="checkbox" name="fancy" value="sport" />运动<br />
<input type="submit" value="存储选择" name="b1" />
</form>
</body>