Free Web Hosting Forum
Go Back   Free Web Hosting Forum > Website Building > Web Programming
Reload this Page need help in event log things for website
Reply
 
Thread Tools Display Modes
(#1 (permalink))
Old
Member
Darryus is on a distinguished road
 
Posts: 32
Join Date: Aug 2011
Default need help in event log things for website - 09-08-2011, 01:24 AM

hi! please help me, i want to create event log for my website,the most important is consist of URL link that the user visited or the URL they passed,the ip address,and the others important things, where the event log would be inserted into mysql database,could you explain how to do that please?what the first step i have to do?
Reply With Quote
Sponsored Links
(#2 (permalink))
Old
Senior Member
grace1004 is on a distinguished road
 
Posts: 544
Join Date: Dec 2010
Default 09-08-2011, 09:49 AM

First, you need to create a log table with the following code:

create table log (
num int(11) not null auto_increment,
ip not null varchar(20),
referer not null varchar(50),
primary key (num)
);

After creating the table, add the following code at the top of the page(s) in your site, for which you want to get
ip address and referer:

<?
$ip = $_SERVER['REMOTE_ADDR']; // user IP address

$referer = $_SERVER['HTTP_REFERER']; // URL link that the user visited or the URL they passed

// put here the script for database connection

if($referer) {
$query = "insert into log (ip, referer) values ('$ip', '$referer')";
mysql_query($query);
}
?>

EDIT:
You can get $referer when the user clicked the URL for your site, in the
previous page that the user was visiting.

Last edited by grace1004; 09-08-2011 at 04:49 PM.
Reply With Quote
(#3 (permalink))
Old
Member
Darryus is on a distinguished road
 
Posts: 32
Join Date: Aug 2011
Default 09-10-2011, 12:09 AM

hi! thanks for your answer, it's very helpful,thanks
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Forum Jump



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.5.2
vBulletin Skin developed by: vBStyles.com