Filling default values into FORMs using SSI

Filling default values into FORMs using SSI

Somebody asked how to insert the caller's host address as the default value into an input field, leaving the user the chance to amend it (if, for example, they are using a proxy, in which case the proxy's IP address or DNS name would appear and they'd want to change that). Here's two methods, using server side includes. Since this is a Server Side Include, it will have been processed by the time that you get it, so you won't be able to see how it has been done. However, I have prepared an alias for the source file, which you can view in order to see the HTML source document before it has been processed for SSI. By the way, this input file gets rejected by all the HTML validators, which is fair enough since an SGML comment isn't valid right in the midst of an HTML construction. However, the Server Side Include feature of the NCSA or Apache HTTPDs honour it just fine; and so a validator that references the URL (and gets the document after it's been processed for SSI) is quite happy with it.

First using REMOTE_ADDR in "TEXTAREA":

Secondly using REMOTE_HOST in "INPUT TYPE=TEXT":

" >

" > HTTP_FROM, if you send one.

(There's a hidden HTTP_REFERER here, if you sent one. Submit the form to find out!!) " > -->

This all works fine, so long as the character string can be inserted into HTML without further processing. If the string contains HTML-significant characters such as ampersand (&), less-than (<) etc., then you'd need to give the matter additional thought, depending on just what context you're dealing with and which characters are expected.