<?php

if (isset ( $_POST ['submit'] ) && $_POST ['checkadmin'] == 'admin') {
	
	$admin = $_POST ['admin'];
	$email = $admin ['email'];
	
	if ($admin ['password'] != '')
		$encrypt_pass = $password->stringbreak ( $admin ['password'] );
	
	$query = $db->exists ( 'users', array ('email' => $email, 'password' => $encrypt_pass, 'suspen_id' => '0' ) );
	
	$usertype = $db->get_col ( "users", array ("email" => $email ), 'type' );
	if ($query) {
		$session->Open ();
		if (isset ( $_SESSION )) {
			$_SESSION ['email'] = $email;
			
			if ($usertype [0] == '0') {
				$session->redirect ( 'home', Admin );
			}
			if ($usertype [0] == '1') {
				$session->redirect ( 'employee_attendence', Admin );
			}
		}
	} else {
		$try = "<p class='text-error'>&nbsp;Username And Password Is Incorrect...</p>";
	
	}
}
?>

<?php
if (isset ( $_POST ['sub_mail'] ) && $_POST ['checkmail'] == 'mail') {
	$umail = $_POST ['mail'];
	echo $email = $umail ['username'];
	$newpass = mt_rand ( 15, 250 );
	$encrypt_pass = $password->stringbreak ( $newpass );
	
	$query = $db->get_row ( 'users', array ('email' => $email ) );
	if (isset ( $query ) && $query ['name'] != '') {
		// echo "ander";
		$update = $db->update ( 'users', array ('password' => $encrypt_pass ), array ('email' => $email ) );
		/*
		 * $db->debug(); $to = $email; $message = "Your New Password
		 * is:$newpass"; $name = $query['name']; $fromname = C_NAME; $return =
		 * $mail->send_email ( $to, $message, $name, $fromname ); if ($return) {
		 * $message="phunch gaya"; }
		 */
	} else {
		?>
<div class="alert">
	<button type="button" class="close" data-dismiss="alert">&times;</button>
	<strong>Oops!</strong> No Such User Found..
</div>

<?php
	
	}
}
?>