<?php
include("include.php");
include("phpfunctions.php");

function admin_login()
{
	$sel=executework("select * from lms_admin where email_id='".$_POST['email_id']."' and password='".$_POST['password']."'");
	$cnt=@mysqli_num_rows($sel);
	if($cnt>0)
	{
		$row=@mysqli_fetch_array($sel);
		$_SESSION['admin_email']=$row['email_id'];
		$_SESSION['login_type']="Admin";
		$_SESSION['login_id']=$row['id'];
		redirect("dashboard.php");
	}
	else
	{
		redirect("index.php?fail=1");
	}	
}

// change Password
function change_password()
{
	
	$sel=executework("select * from lms_admin where id='".$_SESSION['login_id']."' and password='".$_POST['oldpassword']."'");
	$cnt=@mysqli_num_rows($sel);
	if($cnt>0)
	{
		$update=executework("update lms_admin set password='".$_POST['newpassword']."' where id='".$_SESSION['login_id']."' ");
		redirect("change_password.php?succ=1");
	}
	else
	{
		redirect("change_password.php?fail=1");
	}
}

?>