<?php
class Users{
	public $tbName;
	public $userId;
	
	
	public function __construct($tbName, $userId) {
		require_once("connectdb.php");
		$con = new DbConnect;
		$this->con = $con->connect();
		
		$this->tbName = $tbName;
		$this->userId = $userId;
		
	}
	
	function getFirstName(){
		$sql = mysqli_query($this->con, "SELECT * FROM users WHERE user_id = $this->userId ");
		$row = mysqli_fetch_array($sql);
		$firstname = $row['firstname'];
		return $firstname;
	}
	
	function getPassword(){
		$sql = mysqli_query($this->con, "SELECT * FROM users WHERE user_id = $this->userId ");
		$row = mysqli_fetch_array($sql);
		$password = $row['password'];
		return $password;
	}
	
	function getLastName(){
		$sql = mysqli_query($this->con, "SELECT * FROM users WHERE user_id = $this->userId ");
		$row = mysqli_fetch_array($sql);
		$lastname = $row['lastname'];
		return $lastname;
	}
	
	function getUserEmail(){
		$sql = mysqli_query($this->con, "SELECT * FROM users WHERE user_id = $this->userId ");
		$row = mysqli_fetch_array($sql);
		$email = $row['email'];
		return $email;
	}
	
	function isRegisteredEmail($email){
		$sql = mysqli_query($this->con, "SELECT * FROM users WHERE email = '$email' ");
		$count = mysqli_num_rows($sql);
		if($count == 1){
			return true;
		}else{
			return false;
		}
	}
	
	function getFirstNameByEmail($email){
		$sql = mysqli_query($this->con, "SELECT * FROM users WHERE email = '$email' ");
		$row = mysqli_fetch_array($sql);
		$firstname = $row['firstname'];
		return $firstname;
	}
	
	function getUserIdByEmail($email){
		$sql = mysqli_query($this->con, "SELECT * FROM users WHERE email = '$email' ");
		$row = mysqli_fetch_array($sql);
		$user_id = $row['user_id'];
		return $user_id;
	}
	
	
	function getUserPhone(){
		$sql = mysqli_query($this->con, "SELECT * FROM users WHERE user_id = $this->userId ");
		$row = mysqli_fetch_array($sql);
		$phone = $row['phone'];
		return $phone;
	}
	
}




?>