Sonny
|
| Posted: 02/15/2003, 8:22 AM |
|
What I would like to do is create an include page with the ability to retrieve the users IP and count the number of times that IP has been to the site, and move this info to the Members table if and when the user registers.
Users table includes UserID field and Visits field. Would like to use the UserID field as the IP and Visits = 1 on the first visit then add 1 every time the user returns.
|
|
|
 |
Ken
|
| Posted: 02/16/2003, 9:54 PM |
|
Here is a script I wrote that is available for free download from http://www.kabwebs.com. This gets an IP and compares it to a database file to Ban a user from a website. Hope this help you figure out how to get the IP.
The following code is for use with a MySQL Database. Use the SQL code below to create the db on your server. Replace every variable starting with "Your..." with YOUR information.
<?
//Following line used for testing
//echo $REMOTE_ADDR;
//Put IPs into DB and seach for IP
mysql_pconnect("localhost","YourUserID","YourPassword");
mysql_select_db("YourDatabaseName");
$ipaddress = getenv("REMOTE_ADDR");
$ipresult = mysql_db_query ("YourDatabaseName","SELECT ipaddress FROM IPAddresses WHERE ipaddress='$ipaddress'");
if($ipresult) {
if(mysql_fetch_row($ipresult)) {
echo "<p>Entry Denied!</p>";
exit("Your priviliages to view the information contained on this site have been revoked.");
}
}
?>
SQL Code: Don't forget to add IP addresses to the table!
DROP TABLE IF EXISTS IPAddresses;
CREATE TABLE IPAddresses (
ipaddress char(20) NOT NULL default '0',
PRIMARY KEY (ipaddress),
UNIQUE KEY ipaddress (ipaddress)
) TYPE=MyISAM;
|
|
|
 |
Sonny
|
| Posted: 02/17/2003, 12:07 AM |
|
Using ASP and access! Sorry!
|
|
|
 |
|