Navigation  without Java Scripts

Prolog and GCI (Common Gateway Interface)

In this section we explain how to make Visual Prolog communicate with the world wide web through the CGI-interface.

CGI using forms
How forms work
More about CGI and ISAPI

CGI using forms

A common way to make Visual Prolog communicate over the web is by using HTML Forms. A form has at least one Submit button and may have named input fields. After the user has filled out the input fields, he presses the submit button. The form contents are sent to a Visual Prolog program that executes on the server and returns an answer to the user.

Here is a small example with Visual Prolog and CGI scripts, that returns a table containing the name and value of all fields received from the server.

Execute the test CGI script by pressing the "Submit" button on the form below:

Item Name:
Quantity:   
Justify Left CenterRight
Validate:
HTMLpath

Show Visual Prolog Script Source

Show the HTML code for the above form

How forms work

When the Submit button is pressed, the web browser collects the contents of the input fields and their names, encodes them and passes them to the web server using the method defined in the form header. The web server starts the Visual Prolog CGI program and makes the encoded data available to it. The Visual Prolog program can then decode and process the data and return a reply to the user. If the reply conform to the HTML standard, the server accepts it and transmits it to the user's browser, where it is displayed in the same way as any other HTML document . The advantage of the CGI script is that it can process data in real time and send a customized reply to the user.

All FORM-code must be encapsulated in the <FORM .....</FORM>-tags.

The first statement in the HTML code is

<form action="CGI/argtest.exe" method="POST">.

When the Submit button is pressed, it causes the argtest.exe program to be executed on the web server.

The <input type="hidden" name="secret" value="not any more">

code might at first seem a little useless. Because it is hidden, the user cannot see it, so how can this code be usefull to us? The answer is that is is a very convenient method for passing information to and from the application.

The HTML code for the Argument Test Form

<FORM action="CGI/argtest.exe" method="POST">  
<INPUT type="hidden" name="secret" value="not any more">
<TABLE BORDER=1 >
 <TR>
  <TD>Item Name: </TD>
  <TD><INPUT type="text" size="25" name="item"  value="Elephant"></TD>
 </TR>

 <TR>
  <TD>Quantity: </TD>
  <TD><SELECT name="quantity" size="1"><OPTION selected>3</OPTION> <OPTION>4</OPTION>
            <OPTION>5</OPTION> <OPTION>6</OPTION> <OPTION>7</OPTION> </SELECT> </TD>
 </TR>

 <TR>
  <TD>Justify</TD>
  <TD>
    <INPUT type="radio" checked name="justify" value="Left">Left
    <INPUT type="radio" name="justify" value="Center">Center
    <INPUT type="radio" name="justify" value="Right">Right
  </TD>
 </TR>

 <TR>
  <TD>Validate: </TD>
  <TD><INPUT type="checkbox" checked name="validate"></TD>
 </TR>


 <TR>
  <TD>HTMLpath</TD>
  <TD><INPUT type="text" size="20" name="htmlpath" value="127.0.0.1"></TD>
 </TR>
</TABLE>

<INPUT type="submit" value="Submit">
</FORM>
  

More about CGI and ISAPI

Technical information about CGI Scripts
The ISAPI interface (An alternative to CGI)