CGIVariable()
Syntax
Result$ = CGIVariable(Name$)Description
Gets the specified CGI environment variable content. When the CGI is loaded, many information are sent from the web server to the CGI application trough environment variables.
Parameters
Name$ The name of the variable to get. It can be a custom value or one of following predefined constants: #PB_CGI_AuthType : the authentication method used by the web browser if any authentication method was used. This is not set unless the script is protected. #PB_CGI_ContentLength : used for scripts that are receiving form data using the POST method. This variable tells the byte length of the CGI input data stream. This is required to read the data from the standard input with the POST method. #PB_CGI_HeaderContentType : tells the media type of data being received from the user. This is used for scripts called using the POST method. #PB_CGI_DocumentRoot : the root path to the home HTML page for the server. #PB_CGI_GatewayInterface : the version of the common gateway Interface (CGI) specification being used to exchange the data between the client and server. This is usually CGI/1.1 for the current revision level of 1.1. #PB_CGI_PathInfo : extra path information added to the end of the URL that accessed the server side script program. #PB_CGI_PathTranslated : a translated version of the PATH_INFO variable translated by the webserver from virtual to physical path information. #PB_CGI_QueryString : this string contains any information at the end of the server side script path that followed a question mark. Used to Return data if the GET method was used by a form. There are length restrictions to the QUERY_STRING. #PB_CGI_RemoteAddr : the IP address of the client computer. #PB_CGI_RemoteHost : the fully qualified domain name of the client machine making the HTTP request. It may not be possible to determine this name since many client computers names are not recorded in the DNS system. #PB_CGI_RemoteIdent : the ability to use this variable is limited to servers that support RFC 931. This variable may contain the client machine's username, but it is intended to be used for logging purposes only, when it is available. #PB_CGI_RemotePort : the clients requesting port. #PB_CGI_RemoteUser : if the CGI script was protected and the user had to be logged in to get access to the script, this value will contain the user's log in name. #PB_CGI_RequestURI : the path to the requested file by the client. #PB_CGI_REquestMethod : describes the request method used by the browser which is usually GET, POST, Or HEAD. #PB_CGI_ScriptName : the virtual path of the CGI script being executed. #PB_CGI_ScriptFilename : the local filename of the script being executed. #PB_CGI_ServerAdmin : the e-mail address of the server administrator. #PB_CGI_ServerName : the server hostname, IP address Or DNS alias name shown as a self referencing URL. This does not include the protocol identifier such as "HTTP:", the machine name, or port number. #PB_CGI_ServerPort : the port number the HTTP requests and responses are being sent on. #PB_CGI_ServerProtocol : this value is usually HTTP which describes the protocol being used between the client and server computers. #PB_CGI_ServerSignature : server information specifying the name and version of the web server and the port being serviced. #PB_CGI_ServerSoftware : the name and version of the web server. #PB_CGI_HttpAccept : the media types of data that the client browser can accept. These data types are separated by commas. #PB_CGI_HttpAcceptEncoding: the encoding type the client browser accepts. #PB_CGI_HttpAcceptLanguage: the language the client browser accepts. #PB_CGI_HttpCookie : used as an environment variable that contains cookies associated with the server domain from the browser. #PB_CGI_HttpForwarded : the forwarded page URL. #PB_CGI_HttpHost : hostname from where the HTPP requests comes from. #PB_CGI_HttpPragma : HTTP pragmas #PB_CGI_HttpReferer : the page address where the HTTP request originated. #PB_CGI_HttpUserAgent : the name of the client web browser being used to make the request.
Return value
Returns the value of the specified CGI environment variable.
Example
If Not InitCGI() Or Not ReadCGI() End EndIf WriteCGIHeader(#PB_CGI_HeaderContentType, "text/html", #PB_CGI_LastHeader) ; Write the headers to inform the browser of the content format WriteCGIString("<html><title>PureBasic - variables</title><body>") Procedure WriteCGIConstant(Constant$) WriteCGIString(Constant$ + ": " + CGIVariable(Constant$)+"<br>") EndProcedure WriteCGIConstant(#PB_CGI_AuthType) WriteCGIConstant(#PB_CGI_ContentLength) WriteCGIConstant(#PB_CGI_HeaderContentType) WriteCGIConstant(#PB_CGI_DocumentRoot) WriteCGIConstant(#PB_CGI_GatewayInterface) WriteCGIConstant(#PB_CGI_PathInfo) WriteCGIConstant(#PB_CGI_PathTranslated) WriteCGIConstant(#PB_CGI_QueryString) WriteCGIConstant(#PB_CGI_RemoteAddr) WriteCGIConstant(#PB_CGI_RemoteHost) WriteCGIConstant(#PB_CGI_RemoteIdent) WriteCGIConstant(#PB_CGI_RemotePort) WriteCGIConstant(#PB_CGI_RemoteUser) WriteCGIConstant(#PB_CGI_RequestURI) WriteCGIConstant(#PB_CGI_RequestMethod) WriteCGIConstant(#PB_CGI_ScriptName) WriteCGIConstant(#PB_CGI_ScriptFilename) WriteCGIConstant(#PB_CGI_ServerAdmin) WriteCGIConstant(#PB_CGI_ServerName) WriteCGIConstant(#PB_CGI_ServerPort) WriteCGIConstant(#PB_CGI_ServerProtocol) WriteCGIConstant(#PB_CGI_ServerSignature) WriteCGIConstant(#PB_CGI_ServerSoftware) WriteCGIConstant(#PB_CGI_HttpAccept) WriteCGIConstant(#PB_CGI_HttpAcceptEncoding) WriteCGIConstant(#PB_CGI_HttpAcceptLanguage) WriteCGIConstant(#PB_CGI_HttpCookie) WriteCGIConstant(#PB_CGI_HttpForwarded) WriteCGIConstant(#PB_CGI_HttpHost) WriteCGIConstant(#PB_CGI_HttpPragma) WriteCGIConstant(#PB_CGI_HttpReferer) WriteCGIConstant(#PB_CGI_HttpUserAgent) WriteCGIString("</body></html>")
See Also
ReadCGI()
Supported OS
All