/    Sign up×
Community /Pin to ProfileBookmark

I.P. logging Like stats

You know those, stat counters and all.

Well is there a way, to record everyone who visits your sites I.P. addresses?

And then record them into the MySql databases

Is this possible using PHP?

to post a comment
PHP

12 Comments(s)

Copy linkTweet thisAlerts:
@ryeman98Jun 02.2007 — Yes, actually it is possible. I'll do the best that I can to code. (Could be wrong but try it)

<i>
</i>&lt;?php
$ip = $_SERVER['REMOTE_ADDR'];

$query = mysql_query("INSERT INTO <span><code>ip</code></span> (<span><code>ip</code></span>) VALUES ('$ip')");
or die(mysql_error());
?&gt;


Hope that helps!
Copy linkTweet thisAlerts:
@DragonkaiauthorJun 02.2007 — lets try it!
Copy linkTweet thisAlerts:
@DragonkaiauthorJun 02.2007 — What if they go behind a proxy, is there some way to trace it?
Copy linkTweet thisAlerts:
@ryeman98Jun 02.2007 — There probably is but I'm not sure how to do it.

There are two other things that you could do with the IP stuff though. If their IP address is already in the database you could check to see. Something like this:

<i>
</i>&lt;?php
$id = $_SERVER['REMOTE_ADDR'];
$checkIP = mysql_query("SELECT ip FROM <span><code>ip</code></span>);

if ($checkIP == $_SERVER['REMOTE_ADDR'] {

} else {
$query = mysql_query("INSERT INTO <span><code>ip</code></span> (<span><code>ip</code></span>) VALUES ('$ip')");
or die(mysql_error());
?&gt;


or if you have another field in the database which displays how many times the user has been on the page:

<i>
</i>&lt;?php
$id = $_SERVER['REMOTE_ADDR'];
$checkIP = mysql_query("SELECT ip FROM <span><code>ip</code></span>);
or die(mysql_error());

if ($checkIP == $_SERVER['REMOTE_ADDR'] {
mysql_query("UPDATE SET <span><code>number</code></span> = 'i++'");
or die(mysql_error());
} else {
$query = mysql_query("INSERT INTO <span><code>ip</code></span> (<span><code>ip</code></span>) VALUES ('$ip')");
or die(mysql_error());
?&gt;


I'm not actually positive on the second option there but you could easily go to w3schools or tizag and figure out the update part. ?
Copy linkTweet thisAlerts:
@DragonkaiauthorJun 02.2007 — Do you need the code that connected to the database in the first place, and then does all this.
Copy linkTweet thisAlerts:
@lthJun 02.2007 — If there is a proxy,this may help.
[CODE]if(isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
} else if(isset($_SERVER['HTTP_VIA'])) {
$ip = $_SERVER['HTTP_VIA'];
} else if(isset($_SERVER['REMOTE_ADDR'])) {
$ip = $_SERVER['REMOTE_ADDR'];
} else {
$ip = '0.0.0.0';
}[/CODE]
Copy linkTweet thisAlerts:
@DragonkaiauthorJun 03.2007 — So If I included your Code Ith and Rye man 98 code (His 3rd try) together.

What would be the full implementation?
Copy linkTweet thisAlerts:
@ryeman98Jun 03.2007 — I tried my code and it didn't work. I can't seem to get the UPDATE to work for any of my databases so if you're going to use my code, you're going to have to alter it.
Copy linkTweet thisAlerts:
@DragonkaiauthorJun 03.2007 — Oh... hmm Lets do it in steps..

First we need a database...

Then need to check I.P.

Then we trace to proper I.p. if theres a proxy.

We check if I.p. is equal to the database, if not continue, and if yes then proceed to the code

We record the i.p. as a variable and file off to the database..

Done.
Copy linkTweet thisAlerts:
@ryeman98Jun 03.2007 — But now you need to make the code...
Copy linkTweet thisAlerts:
@bokehJun 03.2007 — What if they go behind a proxy, is there some way to trace it?[/QUOTE]No!
Copy linkTweet thisAlerts:
@DragonkaiauthorJun 03.2007 — Well... http://www.auditmypc.com/whats-my-ip.asp

They seem to know when your using a proxy... I think they said something about using java... Maybe thats just because I'm using a proxy that isn't hiding my i.p.

On a side note, I got an I.p. detector saying my external i.p. is one thing... and I got another one saying another.. this is weird.
×

Success!

Help @Dragonkai spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...