According to the fields that uniquely identify the user and ip, you make a unique index in the table so that it would be impossible to insert two records relating to one user-ip bundle into the table. After this, insert a new record in the table as follows:
insert into tableX(ip,user_id,a,b,c,date) values('10.0.0.1',100,'x','y','z',now()) on duplicate key update date=now();
This query either inserts a new record with the data that is in the values, or, if such an entry exists, will update the one specified in the on duplicate key
A unique index on the table is created like this:
create unique index index_name on table_name(ip, user_id);
Since you also need information about the browser, and a user from one computer can use different browsers (and by the way, sometimes the same browser gives slightly different identification lines), the table will need to ensure uniqueness in the ip, user_id, browser fields and maybe some other. If it is difficult, because the application is guided by the complex logic of determining the "that" record, you can try to update the date, if 0 lines were changed (see a function like mysql_affected_rows ), then insert it.