5. Tracking The access
PHP has the ability to detect the browser accessor web page. This lets you create pages which can download tracking visitors. In addition, PHP also able to work with a form that allows web pages collect data used from visitor. Tracking and Form are closely related because both use
global register variables.
Tracking accessor is used to find out the identity accessor. If you penah use extremetracking services,
sitestat, or statcheck, the tracking will provide basic information about the identity of the accessor. Make the following code to create a web page that contains tracking and save it in a format .php.
<html>
<head> <title>
Tracking
</ title> </ head>
<body>
<h1> This is your identity </ h1>
<table border = "1">
<tr> 93
<td> You are using a browser </ td>
<td> <? php print $ _SERVER ['HTTP_USER_AGENT']?> </ td>
</ tr>
<tr>
<td> You use the IP address </ td>
<td> <? php print $ _SERVER ['REMOTE_ADDR']?> </ td>
</ tr>
<tr>
<td> You come here from </ td>
<td> <? php
if (! empty ($ _SERVER ['HTTP_REFERER'])) {
print $ _SERVER ['HTTP_REFERER']; }
else {
print "Nothing brings you here";
}
?> </ td>
</ tr>
<tr>
<td> The page you are viewing is </ td>
<td> <? php print $ _SERVER ['HTTP_HOST']. $ _ SERVER ['PHP_SELF']
?> </ td>
</ tr>
</ table>
</ body>
</ html>
When accessed in a browser, you can see your identity emblazoned on the server, IP address, referrer, the browser type, and the page is opened.
5.1 Display accessor tracking with PHP code |
From the above code, you can know that PHP is able to tracking using a global variable $ _SERVER
which will display the data from the server. $ _SERVER Variable is type of array in which the items in it can be used to tracking, such as:
• $ _SERVER ['HTTP_USER_AGENT']: To determine the type of browser used.
• $ _SERVER ['REMOTE_ADDR']: To know the address IP accessor.
• $ _SERVER ['HTTP_REFERER']: To determine referrers (pages that are used to get to this page).
• $ _SERVER ['HTTP_HOST']: To find out the address of the host server.
• $ _SERVER ['PHP_SELF']: To determine the PHP file being opened.
To produce a good layout, look at the top confinement in in the table so as to produce a great view.
0 komentar:
Posting Komentar