SSI Wysardry
Server Side Includes

Using Server Side Includes to create dynamic pages.



Home / SSI / Dynamic

Back | Next

Using SSI to create pages that are in effect just static documents is not where its real power lies.  To get the best from Server Side Includes, you should consider using the dynamic commands.


Displaying system variables

There are many different system variables that can be displayed using a command in the form of

<!--#ECHO VAR="FILLINTHEBLANK" -->

Note that "FILLINTHEBLANK" is not a real variable - it's something you have to do to make a meaningful command.  Here are some (not all) of the more common variables that can be displayed:-

<!--#ECHO VAR="DATE_LOCAL" -->
The current local date and time.

<!--#ECHO VAR="DATE_GMT" -->
The current date and time in Greenwich Mean Time.

<!--#ECHO VAR="LAST_MODIFIED" -->
The date and time of the last modification of the current document.

<!--#ECHO VAR="DOCUMENT_NAME" -->
The complete local directory path of the current document.

<!--#ECHO VAR="DOCUMENT_URI" -->
The local path of the current document referenced to the base directory.

<!--#ECHO VAR="REFERER" -->
The URL of the page which referred the user to this document.

An example

You could make a dynamic "back" button for your site using the following code:-

<A HREF="<!--#ECHO VAR="REFERER" -->">Back a page</A>

This would create a literal "back" button that took the user back to the page they had previously visited, rather than the previous page in the hierarchy of the site.


Executing CGI scripts

This is one of the most useful things you can do with SSI - run CGI scripts as a page loads.

<!--#EXEC CGI="script.cgi" -->

It depends on how the script is written whether you would actually see an obvious result from this.  The output is not usually sent to the browser.

I'm not sure if Spaceports have the exec cgi command enabled because of the security issues involved.  It is not as risky as exec cmd so it might be worth checking.  I'll update this page if I get a chance to find out.

If you wanted to include the output of a script into your document, you would use the include command from earlier.

<!--#INCLUDE VIRTUAL="/~username/script.cgi" -->

With a combination of these two commands you could (with a lot of work) create a completely dynamic site that displays different versions of the same page for the specific browser or even the language of a particular visitor.

It would be a good idea to look closely at the features available with PHP first though.

Site Menu

Sell t-shirts with your design ... for free!

Section Menu


Copyright © 2000-2003 Wysardry

Most recently updated on 11 May, 2003

Home / SSI / Dynamic

Back | Next


Please feel free to contact us with any comments or suggestions
Server Side Includes
SSI Wysardry

This site is hosted by Spaceports