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

networking - Vagrant-provisioned VirtualBox VM is not reachable from Ubuntu host -

c# - ASP.NET Core - There is already an object named 'AspNetRoles' in the database -

ruby on rails - ArgumentError: Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true -