<?php 

error_reporting(0);

//ADMIN LOGIN
function VALIDATE($user,$pass){
	include '../Admin_config/connection.php';
	$sql= "SELECT * FROM `sc_admin` WHERE `admin_userName`='$user' AND `admin_userPassword`='$pass' AND `ad_status`='Active'";
	$result=mysqli_query($conn,$sql);
	$count=mysqli_num_rows($result);

	if ($count==1) {
		$admin_data=mysqli_fetch_assoc($result);
	    $res = $admin_data;
	} 

	return($res);
}

function FORGET_PASS($admin,$newpass){
 	include '../Admin_config/connection.php';

 	
  	$sql= "UPDATE `sc_admin` SET `admin_userPassword`='$newpass' WHERE `admin_userName` = '$admin'";
  	$result=mysqli_query($conn,$sql);

	if ($result){
		echo '<script type="text/javascript">alert("Password Changed Successfully");';
		echo 'window.location.href = "../views/login.php?password_changed";';
		echo '</script>';
	}else{
		echo '<script type="text/javascript">alert("Error Updating Password");';
		echo 'window.location.href = "../views/changepass.php?error";';
		echo '</script>';
	}
 }

 ?>