Mini SQL 2.0


W3-mSQL : The WWW Interface Package


Welcome to W3-mSQL version 2.0. This product represents the second generation of HTML scripting product developed by Hughes Technologies Pty Ltd. The first generation product provided a simple programatic interface to the mSQL database system from within an HTML document. W3-mSQL 2.0 goes beyond the functionality provided by the first generation W3-mSQL product to enable the development of entire programs within a WWW page while offering comprehensive access control and security features.

W3-mSQL achieves this by providing a complete programming language embedded within an HTML document. The language, called Lite, is similar is style and syntax to the C programming language and the ESL scripting language. Using W3-mSQL and the embedded Lite language, you can generate HTML code "on-the-fly" in the same way you do when you write custom CGI programs. What's more, you can mix normal HTML code with W3-mSQL code so that you only need to use the CGI styled approach where you actually have to.

Scripting Tags

To facilitate the W3-mSQL extensions to normal web pages, Lite code is included in your HTML code. It is differentiated from normal HTML code by including it inside <! > tags. As an example, a W3-mSQL version of the legendary Hello World program is provided below.

	<TITLE>Hello World from W3-mSQL</TITLE>
	<H1>Introduction to W3-mSQL<H1>

	<! echo("Hello World\n"); >


Example 1. Hello World

As you can see, there is a line of code in the middle of the HTML page, enclosed in <! > tags. When the page is loaded through the W3-mSQL CGI program, anything enclosed in <! > tags is parsed and executed as an embedded program. Any output generated by the program is sent to the user's browser. In this case, the string "Hello World" would be sent as part of the HTML page to the browser. The remainder of the page is sent to the browser unmodified.

There can be any number of W3-mSQL tags within a single page and there can be any number of lines of code within a single W3-mSQL tag.

To execute the script depicted in figure 1 you must not just specify the path to the file in the URL as you would normally do. If you do that, your browser will just be sent the unprocessed HTML document. To execute the script you must specify a URL that executes the W3-mSQL binary and tells it to load and process your script. The W3-mSQL binary is called w3-msql and will usually be located in the /cgi-bin directory (if it isn't there contact your system administrator). If the normal URL of a W3-mSQL enhaced web page is /staff/lookup.html, you would load it using the following URL:


This URL instructs the web server to execute the W3-mSQL binary and tells it to load the /staff/lookup.html script file.

Form Data

One thing virtually all CGI type programs have in common is that they process the contents of an HTML form. The form data is passed to the CGI program via either a GET or a POST method by the http server. It is then the responsibility of the CGI script to decypher and decode the data being passed to it. W3-mSQL simplifies this process greatly by converting any form data passed to a script into global Lite variables within the Lite Virtual Machine. These variables can then be accessed by your script code.

When an HTML form is defined, a field name is given to each of the elements of the form. This allows the CGI to determine what the data values being submitted actually mean. When the data is passed to W3-mSQL, the field names are used as the variable names for the global variables. Once a set of variables has been created for each form element, the values being passed to the script are assigned to the variables. This is done automatically during start-up of the W3-mSQL program.

As an example, imagine that the following form was defined in an HTML page

<FORM ACTION=/cgi-bin/w3-msql/my_stuff/test.html METHOD=POST>
<INPUT NAME=username SIZE=20>
<SELECT NAME=user_type>
	<OPTION VALUE="casual">Casual User
	<OPTION VALUE="staff">Staff Account
	<OPTION VALUE="guest">Temporary Guest Account
In the example we have defined 3 fields within the form, 2 text entry fields called username and password, and a menu called user_type. We have also specified that the action for the form is to call W3-mSQL and tell it to process /my_stuff/test.html passing the form data via the POST method. When the data is submitted, the values entered for the 3 form fields are passed to W3-mSQL. It then creates 3 global variables called $username, $password and $user_type, and assigns the user's data to those variables. The values can then be accessed within the Lite script code embedded in test.html by referencing the variables.

The Next Step

To learn more about writing scripts within your W3-mSQL enhanced web pages, see the documentation on the Lite language. Remember that Lite is the scripting language provided within the <! > tags of W3-mSQL. To learn more about the added security and access control provided by W3-mSQL, please see 'W3-mSQL : Security Related Features' and 'W3-auth : Access Control and Authentication.

A fully functional example of a W3-mSQL application is included in the mSQL software distribution. The application is a Web Bookmarks database that allows you to build your own "Yahoo" styled index via web pages. Naturally, the data is stored in an mSQL database and the pages are generated on-the-fly using W3-mSQL. Please see the INSTALL file in the mSQL software distribution for instructions on installing the demonstration application.

Copyright © 1995 - 96 Hughes Technologies Pty Ltd.