<?php
    require_once("db.php");
    class user extends db{

        public function loginuser($database,$username,$password){
            $_SESSION['database']=$database;
            $sql="CALL sp_getuserdetailsbyusername('{$username}')";
            $rst=$this->getData($sql);
            if($rst->rowCount()){
                $rst=$rst->fetch();
                if($rst['accountactive']==false){
                    return "account inactive";
                }else if(md5($password)!=$rst['password']){
                    return "invalid credentials";
                }else if($rst['changepassword']){
                    return "change password";
                }else{
                    $_SESSION['userid']=$rst['userid'];
                    $_SESSION['username']=$rst['firstname'].' '.$rst['lastname'];
                    return "success";
                }
            }else{
                return "invalid credentials";
            }
        }

        public function saveuser($username,$password,$firstname,$lastname,$email,$mobile){
            //$password=md5($password);
        }

        public function getuserdetails($userid){
            
        }
    }

?>