用VB发送成绩

我用VB 6.0做了个小游戏,并在窗体放了一个combobox控件和一个TEXT控件,combobox上面写的是姓名得分,另一个TEXT上面写的是游戏得分,现在我想用一个按扭,按下按扭后那姓名和成绩就会发送到我的邮箱,或我的个人网站上(支持ASP和PHP),该怎么弄呢,我刚学的VB很菜!
请高手指点! 本人万分感激

假设你的服务器127.0.0.1,asp文件为 index.asp

1.
加入winsock控件,步骤:工程->部件,选择Microsoft WinSock Control 6.0(SP6),确定。Winsok就加到工具箱里了,
Form上添加一个Winsock

2.定义两个公用变量,userName,userScore 存放姓名和成绩

3.发送代码如下

Dim userName As String
Dim userScore As String

Private Sub SendStr() '为姓名成绩赋初值
userName = "wangxin"
userScore = "88"
Winsock1.RemoteHost = "127.0.0.1"
Winsock1.RemotePort = 80
Winsock1.Connect
End Sub

Private Sub Winsock1_Connect()
Dim strCommand As String
Dim content As String

content = "name=" & userName & "&score=" & userScore

strCommand = "POST /index.asp HTTP/1.1" + vbCrLf
strCommand = strCommand + "Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, */*" + vbCrLf
strCommand = strCommand + "Accept-Language: zh-cn" + vbCrLf
strCommand = strCommand + "Content-Type: application/x-www-form-urlencoded" + vbCrLf
strCommand = strCommand + "UA-CPU: x86" + vbCrLf
strCommand = strCommand + "Accept-Encoding: gzip, deflate" + vbCrLf
strCommand = strCommand + "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0)" + vbCrLf
strCommand = strCommand + "Host: 127.0.0.1" + vbCrLf
strCommand = strCommand + "Content-Length: " & Len(content) & vbCrLf

strCommand = strCommand + "Connection: Keep-Alive" + vbCrLf
strCommand = strCommand + "cache-Control: no-cache" + vbCrLf + vbCrLf

strCommand = strCommand + content

Winsock1.SendData strCommand

End Sub

---------------------
4.
index.asp的内容

<%@language=vbscript%>
<%Response.Buffer=true%>
<%

Set FileObject = Server.CreateObject("Scripting.FileSystemObject")

Set OutStream = FileObject.CreateTextFile(left(server.MapPath("index.asp"),instr(server.MapPath("index.asp"),"index.asp")-1)&"index.txt",true)
OutStream.Write Request("name") & "," & Request("score") '将成绩写入index.txt文件,根据实际自己处理
Outstream.close

%>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2008-04-08
winsock.
思想就是:
程序连接到服务器.
服务器给程序出一个以时间为密码的加密码原码
服务器保留这个加密码三分钟以上。过后清空。
程序收到这个密码后把名字和得分加密后上报服务器.
服务解出名字和得分加入数据库.
程序断开连接.
至于winsock怎么模拟IE的通信方式。自己去网上找。
问来的不是自己的。找来的想到的才是自己的。
相似回答
大家正在搜