programmingsite : code , tutorials and scripts
Navigation

home


ASP
ASP.net
C
C++
C#
PHP
Java
JavaScript
Powershell
VB.net

Visual Basic


Resources
code
tutorials
training

Ads
Products

 

 

Log Visitors IP addresses in a MySQL database





Log Visitors IP addresses in a MySQL database

OK start up MySQL and then enter the following to create the database .

CREATE DATABASE ipvisits;

USE ipvisits;

mysql> CREATE TABLE visitorsips(
-> ip VARCHAR(50),
-> date VARCHAR(50));

Now we will insert our visitors IP addresses into the database with the following code

<?php
//get the visitors ip address
$ip_address = $REMOTE_ADDR;
//get the date
$the_date = date("Y-m-d");
//connect to MySQL using your details
$conn = @mysql_connect("localhost","username","password") or die("cannot connect to MySQL");
//select the database
@mysql_select_db("ipvisits") or die("cannot connect to the database");
//execute the query
@mysql_query("INSERT INTO visitorsips(ip,date) VALUES ('$ip_address','$the_date')");
//close the connection
mysql_close($conn);
?>

Now you have got a system for logging peoples IP addresses that visit your site







Products
500 Java Tips E-book
PHP editor
PERL editor
Beginning Java
Beginning Visual Basic
Learn VB.net
Learn VB 6
VB and databases
ASP image library
C++ builder programming
C++ fundamentals
Asp Studio 2005
Xtra PHP
Online PHP Script Encoder
Comparison

Links
Make money selling software
Uk shopping
UK price comparison
US price comparison
free articles
free stuff
Gambling resources
Software directory
XBox cheats and more
Sexy free wallpapers
Hosting resources
Nintendo Wii info
Beginners PHP
Health and fitness
Domain names
Dating site
Nintendo DS resources
Dropshippers
Maxi directory
Perfume and fragrances
PC shopping, tips and info
Magazine superstore

Ads