★ wanayoo — archive 1999 http://www.eazyware.com/vb5-cgi/example.htmNouvelle recherche | Portail wanayoo

Examples

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.

Guest Book Live Example:

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).


Speed Live Example:

This example tries to show you the execution speed of a Visual Basic CGI script. Of course, you can't experience the full speed of this example, because the Internet (and the HTTP server) has a limited data transfer rate.
To experience the real speed, you should download this VB5 project (zipped Visual Basic source code, 3k) and run it on your local machine! To invoke the script, please enter your name, number of lines to return (1 to 100) and hit the [Submit] button. A new browser window will be opened, showing the script output.
Your Name:   Return: Lines  


Simple Redirect Live Example:

Do you need a quick solution for redirecting certain IP's, do you use a shared IP for different host names and want to redirect them to different directories, or you want to implement dropdown box navigation without using JavaScript?
This example is very simple, just look at the code of the REDIRECT.EXE (8k) below:
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
Select a page and press [Go!]:
To browse to another location, just enter the URL and press [Go!].
URL:


File Upload Live Example:

Are you looking for a binary file upload solution using HTTP? This example demonstrates a simple file upload for GIF images:

last uploaded image This is the last uploaded image. Refresh this page to see the latest image!

To upload a GIF image (max. 15k), first locate a local GIF image by pressing the [Browse...] button and then hit the [Submit GIF Image] button. After the file was submitted and saved on the server, you will see a status page.

Select GIF file to upload:

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.

Registered users can download the VB5 source code from the Owner's Area.


Remote Ping & Cookies Live Example:

Would you like to know how long it takes for a ICMP packet to travel from MA, USA to another host?
This example shows a server side ping script with the following functionalities:

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.


Email Form Live Example:

Are you looking for an easy but flexible way for sending emails from a script or HTML form?
This example sends an email using SMTP from a HTML form and has the following functionalities:

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.


Credit Card Number Live Example:

This example will show you how easy it is to check for a valid credit card number and optionally for the corresponding credit card company.
To test the script, please enter a credit card number (all characters other than numbers will be stripped) and optionally select the credit card company. After hitting the [check it] button, a new browser window will be opened to show you the result.
Credit Card Number:   Company:

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


Simple Password Example:

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:

  1. The user loads a HTML form and submits a password to the CGI-script.
  2. The script, which is located in the \Scripts directory executes and returns an appropriate HTML text.
  3. As an option, the Library Loader application, which keeps the needed libraries in memory, shows the hit counter value.


Try it live! The password is "Secret" (case sensitive). A new window will be opened to show the status.

Password:


The HTML form below (PASSWORD.HTM) contains a password text field, a submit and a reset button:

Web browser password form 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:

browser with CGI result The returned HTML code from the CGI-script looks like this:
<HTML>
<HEAD>
<TITLE>Test Page</TITLE>
</HEAD>
<BODY>
<CENTER>Valid password was entered 16 time(s)!</CENTER>
</BODY>
</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.

screen-shot of Library Loader application



VB5-CGI Objects Copyright © 1997-1999 by EazyWare Internet and software solutions. E-mail: tools@eazyware.com