Visual Basic 6 Black Book:Deploying Your Program: Creating Setup Programs, Help Files, And Online Registration
function GetCookie (name)
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg) {
var end = document.cookie.indexOf (";", j);
if (end == -1)
end = document.cookie.length;
return unescape(document.cookie.substring(j, end));
}
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
var m1='';
var gifstr=GetCookie("UsrType");
if((gifstr!=0 ) && (gifstr!=null)) { m2=gifstr; }
document.write(m1+m2+m3);
Keyword
Title
Author
ISBN
Publisher
Imprint
Brief
Full
Advanced Search
Search Tips
Please Select
-----------
Components
Content Mgt
Certification
Databases
Enterprise Mgt
Fun/Games
Groupware
Hardware
IBM Redbooks
Intranet Dev
Middleware
Multimedia
Networks
OS
Prod Apps
Programming
Security
UI
Web Services
Webmaster
Y2K
-----------
New Titles
-----------
Free Archive
To access the contents, click the chapter and section titles.
Visual Basic 6 Black Book
(Publisher: The Coriolis Group)
Author(s): Steven Holzner
ISBN: 1576102831
Publication Date: 08/01/98
function isIE4()
{
return( navigator.appName.indexOf("Microsoft") != -1 && (navigator.appVersion.charAt(0)=='4') );
}
function bookMarkit()
{
var url="http://www.itknowledge.com/PSUser/EWBookMarks.html?url="+window.location+"&isbn=0";
parent.location.href=url;
//var win = window.open(url,"myitk");
//if(!isIE4())
// win.focus();
}
Search this book:
Previous
Table of Contents
Next
Uploading Online Registration Information To An FTP Server
In the previous topic, weve stored the registration information we want to upload to the FTP server in a file, temp.dat. To upload the user registration data, we add an Internet transfer control, Inet1, to the onlinereg applications registration form, Form2 (see Chapter 21 for more details on the Internet transfer control).
After writing the registration form to disk, we connect to the FTP server to upload the data to by using the Internet transfer control like this, where we set the controls URL property to the address of the FTP server and set the UserName and Password properties as required:
Private Sub Command1_Click()
Open "c:\temp.dat" For Output As #1
Print #1, "Registering SuperDuperDataCrunch" & vbCrLf
Print #1, "Name: " & Text1.Text & vbCrLf
Print #1, "email: " & Text2.Text & vbCrLf
Print #1, "Time: " & Format(Now)
Close #1
Inet1.URL = "ftp://ftp.server.com"
Inet1.UserName = "steve"
Inet1.Password = "secret"
...
Here we are using the connection protocol used by many FTP servers, which sets the current FTP directory based on the username you log in with. If you need to set the current directory yourself, use the FTP CD command, using the Internet transfer controls Execute method.
TIP: You may want to encode any password that you embed in your code for security purposes.
To actually upload the file temp.dat, we use the Internet transfer controls Execute method to execute the FTP Put command like this, where we name the file reg.dat when uploaded to the server:
Private Sub Command1_Click()
Open "c:\temp.dat" For Output As #1
Print #1, "Registering SuperDuperDataCrunch" & vbCrLf
Print #1, "Name: " & Text1.Text & vbCrLf
Print #1, "email: " & Text2.Text & vbCrLf
Print #1, "Time: " & Format(Now)
Close #1
Inet1.URL = "ftp://ftp.server.com"
Inet1.UserName = "steve"
Inet1.Password = "secret"
Inet1.Execute , "PUT c:\temp.dat reg.dat"
End Sub
This uploads the file with the user registration information to the FTP site youve selected:
Registering SuperDuperDataCrunch
Name: steve
email: steve@steveco.com
Time: 5/5/99 10:02:23 AM
TIP: Note that weve uploaded the file and named it reg.dat on the FTP server; using that name for all uploads will cause a conflict. You should use a unique file name for each separate file; for example, you can incorporate the date and time of day in the file name.
Now that weve uploaded the registration data, we need to terminate the FTP connection and delete the temporary file, and well do that in the next topic.
Concluding The FTP Transfer Of The Online Registration Information
In the previous few topics, weve sent user registration data to an FTP site in the onlinereg application. Now that the upload operation is complete, we will close the FTP connection in the Internet transfer controls StateChanged event handler:
Private Sub Inet1_StateChanged(ByVal State As Integer)
If State = icResponseCompleted Then
Inet1.Execute , "Close"
...
In addition, we delete the temporary file weve created and hide the registration form this way:
Private Sub Inet1_StateChanged(ByVal State As Integer)
If State = icResponseCompleted Then
Inet1.Execute , "Close"
Dim FileSystemObject As Object
Set FileSystemObject = CreateObject("Scripting.FileSystemObject")
FileSystemObject.DeleteFile "c:\temp.dat"
Form2.Hide
End If
End Sub
And thats itweve uploaded the user registration data to the specified FTP site. Congratulations, now youre supporting online registration. The code for this example is located in the onlinereg folder, and the code that displays that form is located in the Form1 folder, both on this books accompanying CD-ROM.
Previous
Table of Contents
Next
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.
Wyszukiwarka
Podobne podstrony:
1066 11068 1treco wiedza artykuly szczegoly id 1066 konflikt reagujUzbrojenie ochronne z czasów bitwy pod Hastings, 10661063 1066więcej podobnych podstron