<?php
class Register{
	public $tbName;
	public $firstname;
	public $lastname;
	public $phone;
	public $email;
	public $password;
	
	public function __construct($tbName, $firstname, $lastname, $phone, $email, $password) {
		require_once("connectdb.php");
		$con = new DbConnect;
		$this->con = $con->connect();
		
		$this->tbName = $tbName;
		$this->firstname = $firstname;
		$this->lastname = $lastname;
		$this->phone = $phone;
		$this->email = $email;
		$this->password = $password;
	}
	
	public function createUser(){
		$query = "INSERT INTO $this->tbName (firstname, lastname, phone, email, password) 
		            VALUES ('$this->firstname', '$this->lastname', '$this->phone', '$this->email', '$this->password' )";
		$res = mysqli_query($this->con, $query);
		if($res){
			return true;
		}else{
			return false;
		}
    }
	
	public function isRegistered(){
		$query = "SELECT * FROM $this->tbName WHERE email = '$this->email' ";
		$res = mysqli_query($this->con, $query);
		$count = mysqli_num_rows($res);
		if($count == 1){
			return true ;
		}else{
			return false;
		}
	}
	
}




?>