php - Updating users login time -


i have login script , want insert last login members table , update every time member logins in having issues. lastlogin not being inserted everytime user logins in. here code

if(isset($_post['submit'])){     $username = $_post['username'];     $password = $_post['password'];      if($user->login($username,$password)){         $_session['username'] = $username;          try{             $stmt = $db->prepare("update admin  set login_date = now() adminid = $adminid ");             $stmt->execute();             $stmt=null;             }         catch (pdoexeception $e){                 $error[] = $e->getmessage();             }         header('location: index.php');         exit;     }    else {                  $error[] =  '<div class="alert alert-danger fade in text-center">                            <a href="#" class="close" data-dismiss="alert">&times;</a>                            <strong>error!</strong>                              wrong username or password or account has not been activated.                       </div>';     } } 

check logic of errors array, try (or similar):

if (isset($_post['submit'])){     $username = $_post['username'];     $password = $_post['password'];     if ($user->login($username,$password)) {         $_session['username'] = $username;         try {             $stmt = $db->prepare("update admin  set login_date = now() adminid = $adminid ");             $stmt->execute();             $stmt=null;         } catch (pdoexeception $e){             $error[] = $e->getmessage();         }     } else {         $error[] = 'wrong username or password ...';     } } if (empty($error)) {     header('location: index.php');     exit; } // show errors foreach($error => $e) {     echo $e; } 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -