Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



Reply
storing IP in mysql database
Old 04-02-2005, 08:35 AM storing IP in mysql database
Super Talker

Posts: 116
Trades: 0
I want to write php script along with mysql database to do the following

It should get the following information about the user and store them in the mysql database

User IP
Referrer
Landing Page
Pages visited during visit
Number of visits during the day
Time spent on visit


How this can be done,any hint in this regard will be highly appreciated
Please also let me know if there are some already made scripts for doing the same
__________________
Code:
if (You are Poor)
{Find a rich Girl Friend and you will be rich)
else
{Find a Girl Friend and you will be poor}
benevolent001 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-02-2005, 09:51 AM
Rufo's Avatar
Extreme Talker

Posts: 173
Trades: 0
Most web stats programs can do this for you. You may already have a suitable script on your server.

If you are writing your own, User IP, Referrer, and Landing Page are easy enough to determine. Look on php.net under 'environmental variables'.

Pages visited during visit, Number of visits during the day, and Time spent on visit are a little harder. How do you plan on identifying multiple impressions from the same user? You can either use session variables, cookies, or IP addresses (only works with static IPs).

Rufo
__________________

Please login or register to view this content. Registration is FREE
Rufo is offline
Reply With Quote
View Public Profile Visit Rufo's homepage!
 
Old 04-02-2005, 10:52 AM
Super Talker

Posts: 116
Trades: 0
I have cpanel which does have weblog script but it doesnt gives useful info like tables it just creates mess into the log.

Do you have script which i can use.
Thanks for your time
__________________
Code:
if (You are Poor)
{Find a rich Girl Friend and you will be rich)
else
{Find a Girl Friend and you will be poor}
benevolent001 is offline
Reply With Quote
View Public Profile
 
Old 04-02-2005, 10:54 AM
Super Talker

Posts: 116
Trades: 0
I am bascially looking to detect illegal clicks as i am using adwords for getting traffic
__________________
Code:
if (You are Poor)
{Find a rich Girl Friend and you will be rich)
else
{Find a Girl Friend and you will be poor}
benevolent001 is offline
Reply With Quote
View Public Profile
 
Old 04-08-2005, 04:20 PM
x2digital's Avatar
Novice Talker

Posts: 14
Trades: 0
This is easy!

Firstly, you'll need to get all of the details:
PHP Code:
    $agent $_SERVER['HTTP_USER_AGENT'];

    
$uri $_SERVER['REQUEST_URI'];

    
$user $_SERVER['PHP_AUTH_USER'];

    
$ip $_SERVER['REMOTE_ADDR'];

    
$ref $_SERVER['HTTP_REFERER'];

    
$dtime date('r'); 
Now, the username and referrer details can sometimes be empty, so lets fill them with something.

PHP Code:
    if($ref == ""){
        
$ref "None";
    }
    if(
$user == ""){
        
$user "None";
    } 
Now, connect to your database.

PHP Code:
        $dbhost "localhost";
        
$dbuser "username";
        
$dbpass "password";
        
$dd "database";
    
$connection mysql_connect($dbhost$dbuser$dbpass) or die(mysql_error());
    
mysql_select_db($db$connection) or die(mysql_error()); 
Lastly, insert the details into the database. Lets say the table is "Visitors"

PHP Code:
$sql "INSERT INTO `Visitors` VALUES (ip="$ip", url="$uri".......)";
mysql_query($sql) or die("Error"); 
The .... is where you enter the rest of the details. You get the picture.
Hope this helps!
__________________
Kind Regards,

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
x2digital is offline
Reply With Quote
View Public Profile Visit x2digital's homepage!
 
Reply     « Reply to storing IP in mysql database
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15294 seconds with 12 queries