登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

面包会有的

... ...

 
 
 

日志

 
 

xmlhttp发送用户名和密码实现登陆  

2008-08-06 17:00:11|  分类: 默认分类 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

login.asp

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
<!--
.STYLE1 {color: #0066CC}
-->
</style>
</head>
<body>
<%
Response.Write "username="&Request("username")&"<br>"
If Request("username") = "xiaoxiao"Then

 Session("UserName") = "xiao"
 Response.Write "<br>Current:Session(""UserName"")="&Session("UserName")&"<br>"
 Response.Write ""
 response.cookies("UserName")="test"

Else
 Response.Write "验证错误,用户名或密码有误"
End If
 response.cookies("Un")="123"
%>

<%
If Session("UserName") = "xiao" Then

 Response.Write "<br>HaveLogin"
End If
%>

 

trylogin.asp

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<%
Function GetResult(urlStr)
Dim xmlHttp
Dim retStr
Set xmlHttp = CreateObject("Msxml2.XMLHTTP") '创建对象
On Error Resume Next '出错处理
xmlHttp.Open "POST", urlStr, False '用POST方式打开连接,异步执行。
xmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded" '上传表单
xmlHttp.Send "username=xiaoxiao&userpwd=111111&usercookies=0" '发送指令
If Err.Number = 0 Then '如果连接正确
retStr = xmlHttp.responseText '等待并获得服务端返回的结果字符串
Else
retStr = "Url not found" '否则返回出错信息
End If
Set xmlHttp = nothing '释放对象 GetResult = retStr '返回结果
Response.Write retStr
End Function
%>

<%
GetResult "http://www.1.com/login.asp"
%>

将这两个文件放在同一个域名下可以测试。

测试结果类似于:
username=xiaoxiao

Current:Session("UserName")=xiao

HaveLogin

出现以上测试结果,说明成功登陆。

 

 

  评论这张
 
阅读(2348)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018