<?php
	include_once("../config.php");
	include_once("../functions.php");
	include_once("../library/encryption.php");
	$converter = new Encryption;
	session_start();
	if(isset($_SESSION['objLogin'])){
		$data = post_input_serilization();
		if(isset($data['txtProfilePassword']) && $data['txtProfilePassword'] !== ""){
			$name = !empty($data['txtProfileName']) ? $data['txtProfileName'] : '';
			$email = !empty($data['txtProfileEmail']) ? $data['txtProfileEmail'] : '';
			$contact = !empty($data['txtProfileContact']) ? $data['txtProfileContact'] : '';
			$password = hash_password($data['txtProfilePassword']);
			$sql = '';
			if($_SESSION['login_type'] === 'admin'){
				$sql = "UPDATE `admins` set name = '$name', email = '$email', contact = '$contact', password = '$password' where user_id = $data[user_id]";
				echo $sql;
			}
			else if($_SESSION['login_type'] === 'super'){
				$sql = "UPDATE `tblsuper_admin` set name = '$name', email = '$email', contact = '$contact', password = '$password' where user_id = $data[user_id]";
				echo $sql;
			}
			if($link->query($sql)){
				echo "1";
				die();
			}
			
		}
		else{
			echo '-99';
		}
	}
	else{
		echo '-99';
		die();
	}
?>
