here is a very simplified example (not much error checking). you didn't mention which database you are using but i will assume you are using mySQL and that your data structure looks something like this:
table: users
user_id (int) PK
email (varchar)
password (varchar)
timestamp (timestamp)
times_visited (int)
this example also assumes your have already put email and password into the session that that you are already connected to the database:
$result = mysql_query("SELECT * FROM users WHERE email = '" . $_SESSION['email'] . "' AND password = '" . $_SESSION['password'] . "'");
if (mysql_num_rows($result))
{
$row = mysql_fetch_assoc($result);
$times_visited = $row['times_visited'] + 1;
$result_update = mysql_query('UPDATE users SET times_visited = ' $times_visited);
{
if ($result_update) {echo 'you have now vistited ' . $times_visited . ' times';}
}
}
else
{
$result_insert = mysql_query('INSERT INTO users SET
email = '" . $_SESSION['email'] . "',
password = '" . $_SESSION['password'] . "',
times_visited = 1");
if ($result_insert) {echo 'your data has been entered in our database';}
}
note that you do not need to update the timestamp field, mySQL will do that for you automagically.