Programming.a.baby - (Asp) Server Variables Samples
By pol1ce
Article 9
Requesting Svar Samples
Like as you read in the last article (Programming.a.baby - (Asp) Object Request Server Variables List), here there are the samples for the Object Request Server Variables
There is something, that you have to know first:
- If your web page is hosted in a foreign web server, they may not let you use the majority of the Server Variables, you can always try to contact them asking which you can and cannot use
- Also take care how you use them, since some of it will reveal some information that you may want to hide from visitors
- We will work with the most common first, so you can easy learn
.
.
...
Doing the Request of a IP Address
So, you want to know what is the IP address of the user that is in the Web Site
As you see in the following Sample 1 - Asp code:
- First we declare a VARiable with the name "IP" or other you chose
- After we store info in the "IP" VAR with the Request from to the server
- Then we do what we want with the info, for example we can write it
Sample 1 - Asp Code
<%
Dim IP
IP = Request.ServerVariabes("remote_addr")
Response.Write "The IP is: <strong>" & IP & "</strong>"
%>Sample 1 - Html Output
The IP is: 123.123.123.123
.
Request the Browser Type
What kind of Web Browser is the person using to explore your Web Site?
You can have this information with the following Sample 2 - Asp Code
Sample 2 - Asp Code
<%
Dim IP
Browser = Request.ServerVariabes("http_user_agent")
Response.Write "The Browser is: <strong>" & Browser & "</strong>"
%>Request the Referer
Do you want to know if the visitor came from other Website clicking a URL to your Web Site, Then lets request the Referer Server's Variable
- If there is a Referer taht means he did click a url somewhere
- If not, then he use a bookmark from his browser or a desktop shortcut
I will give you two peaces of code examples
- In the Sample 3.1 you have the simple way
- In the Sample 3.2 you can use the "IF" Statement to write one of two possible phrases, depending on what is happening
Sample 3.1 - Asp Code
<%
Dim Came_from
Came_from = Request.ServerVariabes("http_referer")
Response.Write "User came from: <strong>" & Came_from & "</strong>"
%>Sample 3.2 - Asp Code
<%
Dim Came_from
Came_from = Request.ServerVariabes("http_referer")
If Came_from = "" Then
Response.Write "User click a Bookmark"
Else
Response.Write "User came from: <strong>" & Came_from & "</strong>"
End If
%>Other Articles for Asp
.
Next -->
Programming.a.baby - (Asp) Object Request Cookies
|||
<-- Previous
Programming.a.baby - (Asp) Object Request Server Variables
Programming.a.baby - (Asp) Object Request Form
Programming.a.baby - (Asp) Object Quiz
Programming.a.baby - (Asp) Object Request
Programming.a.baby - (Asp) Object Response
Programming.a.baby - (Asp) The Asp Variables
Programming.a.baby - (Asp) My first Asp Page
Programming.a.baby - (Asp) Asp what is it
.
Comments
No comments yet.