<?php
class Register{
	public $tbName;
	
	public function __construct($tbName) {
		require_once("connectdb.php");
		$con = new DbConnect;
		$this->tbName = $tbName;
		$this->con = $con->connect();
		
	}
	
	public function signUp($firstname, $lastname, $email, $phone, $contact_address, $shipping_address, $password){
		//password encrypt using SHA256();
		$password = hash('sha256', $password);
		$sql = mysqli_query($this->con, "INSERT INTO $this->tbName (first_name, last_name, email, phone, c_address, s_address, password) 
		       VALUES ('$firstname', '$lastname', '$email', '$phone', '$contact_address', '$shipping_address','$password')");
							
	    return $sql;
	}
	
	public function isSignedUp($email, $password){
		//password encrypt using SHA256();
		$password = hash('sha256', $password);
		$sql = mysqli_query($this->con, "SELECT * FROM $this->tbName WHERE email = '$email' ");
		$row = mysqli_fetch_array($sql);
		$data['userCount'] = mysqli_num_rows($sql);
		$data['accountId'] = $row['account_id'];
		
		
		return json_encode($data);
	}	
}




?>