<?php
class Login{
	public $tbName;
	public $email;
	public $password;
	
	public function __construct($tbName, $email, $password) {
		require_once("connectdb.php");
		$con = new DbConnect;
		$this->con = $con->connect();
		
		$this->tbName = $tbName;
		$this->email = $email;
		$this->password = $password;
	}
	
	public function getUser(){
		$query = "SELECT * FROM $this->tbName WHERE email = '$this->email' AND password = '$this->password'";
		$res = mysqli_query($this->con, $query);
		$count = mysqli_num_rows($res);
		if($count == 1){
			return true ;
		}else{
			return false;
		}
	}
	
	public function userId(){
		$query = "SELECT * FROM $this->tbName WHERE email = '$this->email' AND password = '$this->password'";
		$res = mysqli_query($this->con, $query);
		$row = mysqli_fetch_array($res);
		$userId = $row['user_id'];
		
			return $userId ;
		
	}
	
	public function getFirstname(){
		$query = "SELECT * FROM $this->tbName WHERE email = '$this->email' AND password = '$this->password'";
		$res = mysqli_query($this->con, $query);
		$row = mysqli_fetch_array($res);
		$firstname = $row['firstname'];
		
			return $firstname ;
		
	}
}




?>