how i can detect visitors IP?? i have sessions script if needed.
how i can detect visitors IP?? i have sessions script if needed.
The following PHP snippet displays the IP address of the visitor to the page.
Code:<?php echo$_SERVER['REMOTE_ADDR'];?>
"Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design
but what if i want to save ip on sql?? maybe i need to save it when they registering? thanks
however, note that even under normal circumstances, many users may not have the same IP every time they connect - so using the IP to validate something (if that's what you're trying to do) won't always work.PHP Code:$userIP = $_SERVER['REMOTE_ADDR'];
// adjust SQL to suit your table/other values
// use UPDATE instead if you're updating existing rows
$IPsql = mysql_real_escape_string("INSERT INTO userIPaddr (userIP) values ('$userIP')");
//assumes you have already connected to your DB
mysql_query($IPsql);
auriaks (10-21-2009)
That's true, especially with networks, where there are many people connected, whose information is all passed as one IP by the router, so if you have one person in that network whose paid for a service, and you allow them access, it could mean that everyone else on that network could get through too.
It would also work the other way round, where someone might be blocked, and then it block everyone on the network, which may cause more problems.
I don't want to create IP ban or smth... thanks for warningsTRAQ, all lines i have to write after connection script?? and what variables i have to create in the db->table to fit your written script? Many thanks..
what database columns? In my example above, I used the column name "userIP". You could name it anything you wanted.
It works... thxCan you take a look to this Q?? Question for rewriting script
Last edited by auriaks; 10-21-2009 at 08:19 PM.
Bookmarks