Transfer and data processing by means SSI

Data transfer (1-st way):


The data are passed the same way, as well as for usual html files - through URL or with the help of the form method GET. Basically, and to process them it is possible the same way. But, if you want to change a SSI-insert depending on the transferred{handed} data, read further.

Features:


For SSI it is better to pass the data as name=value. Method GET of the form and does{makes}, and if you independently form a line of search, she should look so:



file.shtml? var1=value1*var2=value2, etc.



Data acquisition:


It is not enough to us to pass the data. We should also receive them. To see, that we there have passed ourselves, switch on in a file a line



<! - *printenv->


This line further is not required to us. She it is necessary to see only, whether it is passed though something. Further if something not so will go, insert this line into a file and check up, can you somewhere not so bukovku have written.



The most simple way of use:


We admit{allow}, you on a site have FAQ, but answers to questions such volumetric, that it would be desirable to deduce{remove} them on one and thus, if then prispichit to change design for a long time to not potter. We do{make} one page (we shall name her{it} faq.shtml), we make out her{it} as it is necessary, and in that place where there should be an answer, we write



<! - *include virtual = " $ {file} "->


Take into account, that can be, for your server it is necessary to use not figured, a parentheses or even in general without them to do without.

Now answers to questions we write everyone in the html-file in which there is nothing, except for the text yes tegov, with it{him} connected (B, FONT and t.d), and it is desirable to not use attributes COLOR, that then not muchat`sja.

It is necessary to do{make} links to answers as follows



<a href = " faq.shtml? file=url ">


Where url - the address of the html-file containing the answer, it is possible relative - only look do not get confused.


Basically, all site can be organized by such principle. If you like to change design that it to make, will enough change only one file - and at you a new site.



Data processing:


All this is good. But it would be desirable still something pokhitree. If you are already familiar with SSI, you are farther new do not learn{find out}, if no - read.

In files SSI it is possible to use variables. They appear so:



<! - *set var = "name" value = "value"->


Data transfer



file.shtml? username=Alexey*birth=1974


It is equivalent



<! - *set var = "username" value = "Alexey"->

<! - *set var = "birth" value = "1974"->


Opportunities on use of these invaluable data in SSI are enough limited, but we can try with them something to make.


It is possible to insert a variable into the document simply:



<! - *echo var = "name"->


For example, using the data transferred{handed} earlier, it is possible to write



Greetings, <! - *echo var = "username"->


Therefore on the screen Greetings, Alexey will appear

The example is more complex{difficult}. If in a file to write



<! - *set var = "title" value = "heading"->


That then in a causing file can be used



<title> <! - *echo var = "title"-> </title>


Thus, we can pass from included files in caused various confidential informations. The user does not see instruction SSI - they are processed by the server and passed already in final, " ready to the use " a kind.


It is possible poizvrahhat`sja and to try to analyse the transferred{handed} data and on their basis something to make.


Conditional operators look so:



<! - *if expr = "condition"->

<! - *elif expr = "condition"->

<! - *else->

<! - *endif->


The element endif is obligatory. elif it is possible to repeat some time. After if and elif the HTML-code which will be substituted at the validity of a condition is written. After else the code which will be substituted if any of available before conditions was not executed is written.


For example:



<! - *if expr = ' " $ username ' = "Alexey" '->

<h1> Greetings, <! - *echo var = "username"-> </h1>

<! - *else->

<h2> Greetings, <! - *echo var = "username"-> </h2>

<! - *endif->


Such simple code deduces a greeting but if the person call Alexey, letters will be slightly more.



Data transfer (2-nd way)


It is possible to pass the data and means SSI. Plus at this method that he, as against the first way, passes unnoticed for the user. To pass the data, it is necessary to appropriate{give} them what nibud` a variable. All variables declared in a file, are accessible both in caused, and in causing files. But!!! Itself coboj certainly, that it is necessary to connect all over again a file, and then to use the data available in him, and in connected files to use that is present by the moment of connection is possible only.




The second way of the organization of a site:


He is a little bit more complex{difficult}, but (imkho) it is more progressive.

All clauses{articles} we write in a format html, but we avoid application tegov, changing color, and it is not specified body. We save (it is allowable in a file text.html), and we remember the address of this file. To anybody it{him} we do not speak - he will be for especially internal use.

Now we create a "public" file for this clause{article}, we shall bring it{him} in catalogues and to recommend familiar. He will consist all of several lines.



<html>

<! - *set var = "description" value = "description"->

<! - *set var = "title" value = "Heading"->

<! - *set var = "keywords" value = "keywords"->

<! - *set var = "file" value = " url clauses{articles} "->

<! - *include virtual = " a file interfejsa.shtml "->


As you can see, we have specified in him heading, keywords, the description and a "private" file which contains clause{article} (text.html). It is possible to write still that you there still usually write in heading. I am limited by one title more often. Somehow easy I concern to that relevance small appears:-).

Now we create a file of the interface (*, shtml). The beginning of it{him} looks so:



<html> <head>

<title> <! - *echo var = " $ title "-> </title>

<meta name = "description" content = " <! - *echo var = " $ description "-> ">

<meta name = "keywords" content = " <! - *echo var = " $ keywords "-> ">

</head>


Further we make out appearance - we hang up banners, we insert counters, we add news, etc. At last in that ugolke where there should be clause{article}, we write



<! - *include virtual = " $ file "->


Now for radical change of design of all site it is enough to change only our file of the interface.

Nuances

Depending on a situation and as the various software there can be miscellaneous a syntax of a spelling of names of variables. If all of you have made as here is written also has left nothing, try the following:

Insert a line <! - *printenv->

Also see, whether is in general at you though any variables. If is, but to use them it is impossible, try other way of a spelling:



"name"

"$name"

$name

" $ {name} "

" $ (name) "



One of them will work.


If for you does not work even printenv, Probably, you all over again need to make the server of the computer. The most simple way - to establish program Small Http Server. The instruction in Russian is simple in installation and use. After installation can test on computer CGI, SSI, PHP, etc.


Not always and not everywhere it is possible to receive transferred{handed} through URL given in the way described above. In most cases you can pass only one value file.shtml? value. The value transferred{handed} thus value is stored{kept} in variable QUERY_STRING or QUERY_STRING_UNESCAPED if you extremely needed to pass letters of Russian alphabet. However, can appear so, that on your server even access to QUERY_STRING is not stipulated. Use printenv to define{determine} it. If this directive shows, that among accessible variables QUERY_STRING and does not smell, you need possible{probable} to be passed given only means SSI. If QUERY_STRING is, but at attempt to pass some values in a variable are saved also an equal-sign, and ampersant (?), the server preliminary analysis of the entering data means does not carry out and does not perceive transmitted values as pair variable - value.