I have come up with the following solution:
CREATE TABLE logger
(
id
int(11) NOT NULL AUTO_INCREMENT,
ip
int(11) NOT NULL,
landing
varchar(16) DEFAULT NULL,
updated
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (id
)
) ENGINE=InnoDB DEFAULT CHARSET=latin1
See if entry exists select id, landing from logger where ip = INET_ATON('10.0.5.9') and updated > date_add(CURRENT_TIMESTAMP,interval -2 DAY) order by id desc limit 1;
If exists update. This shall automatically update the updated field update logger set landing = 'landing' where id = 1;
If not exist add the entry insert into logger (ip, landing) value (INET_ATON('10.0.5.9'), '/');
Could anyone help me with the php bits to add into my headers as i have successfully sorted the MySQL bits now.
Thanks in advance guys!
if
statement or something similar). Using the global variable$_SERVER['REMOTE_ADDR']
you can get a user's IP. I wouldn't suggest using IP's for this, since they can easily be changed or shared. Maybe read how the user got on the page, then set a cookie based on that? - BananaMan