Update db row on login
<p>I have the following code: its purpose is very clear => at login update db with +1 logins for totallogins and record the time of the very last login. The only downside is that it wont work.</p>

<pre><code>&lt;?php

date_default_timezone_set('Europe/Amsterdam'); 

if (isset($_POST['formsubmitted'])) {
$Timesloggedin = "SELECT * FROM members.Timesloggedin WHERE Email='$email'";
$time = date("Y-m-d H:i:s"); 
$query1 = "UPDATE members SET Timesloggedin = $Timesloggedin + 1, Lastloggedin = $time WHERE Email ='$email'";

$result_insert_loggedins = mysql_query($query1);
if (!$result_insert_loggedins) {
    echo 'Query failed';
}

if (mysql_affected_rows($dbc) == 1) 
{ 
    //If the Insert Query was successfull.
} 
?&gt;
</code></pre>
