php code needed

Status
Not open for further replies.

REY619

Ambassador of Buzz
can someone tell me the php code to know the last page of the visitor, i.e. from where the visitor came?? and writes every info about the visitor in a text file!!??
Can anyone help me?
Thanx.
 

bukaida

In the zone
problem is not very clear. Do you want to track the ip address, time of visit , number of visit etc information of the visitor?
 

mediator

Technomancer
thats very easy. But instead of file u shud use mysql!
*www.plus2net.com/php_tutorial/php_ip.php
*www.w3schools.com/php/php_file.asp
 

Choto Cheeta

Rebooting
well in that case all best hosting comes with softwares like AWStats :p which doo all this job for u very professionally :)

also if not, then u still can use Statcounter

:)
 
OP
R

REY619

Ambassador of Buzz
Hmm well look at this::
Code:
<?php
session_start();
if($_SESSION["logged"] != "yes")
{
$agent = $_SERVER['HTTP_USER_AGENT'];
$uri = $_SERVER['REQUEST_URI'];
$ip = $_SERVER['REMOTE_ADDR'];
$ref = $_SERVER['HTTP_REFERER'];
$visitTime = date("r"); //Example: Thu, 21 Dec 2000 16:01:07 +0200


$logLine = "$visitTime - IP: $ip || User Agent: $agent || Page: $uri || Referrer: $ref\n";
$fp = fopen("visitorLog.txt", "a");
fputs($fp, $entry_line);
fclose($fp);
$_SESSION["logged"] = "yes";
}
?>
According to this code it should write the information about the visitor in the file visitorLog.txt but it doesnt write anything to it. Both this php file visitorLog.txt are in the same directory, and i have chmodded visitorLog.txt to 777 too, but still it is blank...
Does anybody know, where is the error?/ Thanx.
 

ravi_9793

TechTin.com
I think the best suggestion is of saurav_cheeta ..
*www.statcounter.com/

I am using this..it is simple n great.
 

ahref

In the zone
@REY619 you are storing the data in $logLine and writing $entry_line, use same variable at both place.
 
OP
R

REY619

Ambassador of Buzz
Damn!! How did i missed that??!! Thank you HyperReference :D
__________
its working now, thanx :)
 
Last edited:

Saharika

In the zone
ravi_9793 said:
I think the best suggestion is of saurav_cheeta ..
*www.statcounter.com/

I am using this..it is simple n great.
but should also list it is not free for pro use..only keeps logs on last 100 users and always lures u to buy thier paid version...
nice for small and non pro sites...only .Their free version..
 
Status
Not open for further replies.
Top Bottom