| ★ wanayoo — archive 1999 http://www.eazyware.com/vb5-cgi/example.htm | Nouvelle recherche | Portail wanayoo |
Following, some live examples which run on my ISP's IIS4 web server:
Guest Book,
Speed,
Redirect,
File Upload,
Remote Ping
Email Form and
Credit Card Number.
To get a general overview, have a look to the Simple Password example.
More examples (e.g. DAO/ODBC database access, cookies, custom Chinese decoding) can be found in the free downloadable TRIAL EDITION.
The first live example is a small guest book CGI-script using the VB5-CGI Objects, which supports the following functionality:
Click the following link to execute the script and show the guest book in a new browser window. Your guest book entries will only be shown in this example guest book.
To view the VB5 code, either download the TRIAL EDITION or just download this single VB5 project (zipped Visual Basic source code, 4k).
Private CGI As New VB5CGI.clsCGI
Private HTML As New VB5HTML.clsHTML
Private RedirectURL As String
Private Sub Main()
With HTML
If .InitQueryString Then
RedirectURL = .GetKeyString("URL") 'Get the URL parameter value
If Len(RedirectURL) > 0 Then
CGI.Redirect = RedirectURL
Else 'No parameter value was submitted
.SubmitPage "Redirect Error", "Please specify a URL value", True
End If
Else 'No query string was submitted
.SubmitPage "Redirect Error", "Please specify the URL parameter", True
End If
End With
End Sub
To browse to another location, just enter the URL and press [Go!].
This is the last uploaded image. Refresh this page to see the latest image!
Note: The CGI can save any kind of data (binary file), the web server limits the maximum file size.
Only Netscape Navigator from version 2 and Microsoft IE from version 4 (IE3 with plugin) support the file upload functionality!
Please reload the page if you can't see your newly uploaded image.
The Remote Ping script (in a new window) initially shows your IP in the host input field. To ping another host, simply enter the hostname or IP and press [Ping!].
Feel free to link to this ping script. If you like you can customize the script by providing parameters, just copy the following line:
<A HREF=/old?u=http%3A%2F%2Fwww.eazyware.com%2Fvb5-cgi%2F%26quot%3Bhttp%3A%2Fwww.eazyware.com%2Fvb5-cgi%2Fscripts%2Fremoteping.exe%3Fhost%3D...%26amp%3Bcount%3D3%26amp%3Bsize%3D32%26amp%3Bttl%3D30%26quot%3B%26gt%3BPing&y=1999 ...!</A>
If you don't supply a valid parameter, the script will automatically correct it and show you the performed changes.
Registered users can download the VB5 source code from the Owner's Area.
Test the Email Form (in a new window) by sending an email to your own email account.
Registered users can download the VB5 source code from the Owner's Area.
If you are afraid that someone collects your credit card number, just copy-paste the code below to a VB module, compile it and run it on your own web server. Note that VB5-CGI Objects version 2.03 or higher must be installed on the server system.
Private HTML As New VB5HTML.clsHTML
Sub Main()
Dim msg As String
Dim ccnumber As String
With HTML
.InitQueryString True
ccnumber = HTML.GetKeyString("CCNumber")
If .IsCreditCardOk(ccnumber, .GetKeyLong("CCCompany")) Then
msg = "The credit card number " + ccnumber + " is valid."
Else
msg = "The credit card number " + ccnumber + " is NOT valid."
End If
.SubmitPage "Credit Card Check", "<H3>" + msg + "</H3>", True
End With
End Sub
The following example illustrates some basic
techniques, on how the VB5-CGI Objects work.
The used browser is Netscape 3.01 Gold and the Web server is Microsoft Personal
Web Server 1.0a under Windows 95.
It consists on the following three steps:
Try it live! The password is "Secret" (case sensitive). A new window will be opened to show the status.
The HTML form below (PASSWORD.HTM) contains a password text field, a
submit and a reset button:
|
Show the HTML code in a separate browser window. |
1. After entering the correct password "Secret" and pressing
the "Submit Password" button, the form data will be submitted to
the Web server using the POST method.
2. The Web browser executes and submits
the received data to the Visual Basic CGI script pwd.exe, which uses the
two objects VB5CGI and VB5HTML.
Show the Visual Basic 5 source code in a separate browser window.
Because the correct password was submitted, the CGI script returns the following message:
![]() |
The
returned HTML code from the CGI-script looks like this:
<HTML> |
| 3. This screen-shot
shows the optional Library Loader application, which can be used
to load needed script libraries in the server's memory and edit certain
hit counter values.
It shows the "PWD" hit counter value, which was created by the CGI-script. Note that for this example, only the VB5HTML.DLL was explicitly loaded. The VB5CGI.DLL and MSVBVM50.DLL get loaded automatically at startup of the Library Loader application. |
![]() |
VB5-CGI Objects Copyright © 1997-1999 by EazyWare Internet and software solutions. E-mail: tools@eazyware.com