<?php
###################################### Login Validate ###################################################################
//fetching data from index.html
$username=$_POST['username'];
$secque=$_POST['secque'];
$ans=$_POST['ans'];

if($username=='' || $secque=='' || $ans=='')
	{  		
		echo "<script type='text/javascript'>alert('Please Enter Username Or SecurityQuest Or Answer!')</script>";
		echo '<script language="JavaScript"> window.location.href ="forgotpswd.php" </script>';		
	}
//including database file
require_once('connection/db.php');
session_start();

$query=mysql_query("SELECT security_ques,sec_ans,password from login where user_name='$username' ");
$result=mysql_fetch_array($query);


if($result['security_ques']==$secque && $result['sec_ans']==$ans)
{
	$pswd=$result['password'];
	echo "<script>alert('Your password is: $pswd')</script>";
	echo '<script language="JavaScript"> window.location.href ="index.php" </script>';		
}
else
{
	echo "<script>alert(' You have entered wrong information!!!!!!!!! ')</script>";
	echo '<script language="JavaScript"> window.location.href ="forgotpswd.php" </script>';	
}










//sql query
/*$qry="SELECT * FROM login WHERE login_id='$username' AND password='$password'";
$rs=mysql_query($qry);
//validating resultset
$count=mysql_num_rows($rs);
if($count==0)
	{	
		echo "<script type='text/javascript'>alert('Invalid User Name or Password!!..')</script>";
		echo '<script language="JavaScript"> window.location.href ="index.php" </script>';			
	}
while($row=mysql_fetch_array($rs))
	{	
		if($row['login_id']==$username && $row['password']==$password)
			{  
				######################## If User Is Desk ##########################
				if($row[user_type]=="Desk")
					{
						$_SESSION['logged_in'] = true;
						$_SESSION['User_Name'] = $_POST['username'];
						
						echo '<script language="JavaScript"> window.location.href ="deskacceptletter.php" </script>';
						exit;
					}
				######################## If User Is Tapal ##########################
				if($row[user_type]=="Tapal")
					{
						$_SESSION['logged_in'] = true;
						$_SESSION['User_Name'] = $_POST['username'];
							
						echo '<script language="JavaScript"> window.location.href ="tapal_home.php" </script>';
						exit;
					}
						
				######################## If User Is BDO ##########################
				if($row[user_type]=="BDO")
					{
						$_SESSION['logged_in'] = true;
						$_SESSION['User_Name'] = $_POST['username'];
						echo '<script language="JavaScript"> window.location.href ="bdo_home.php" </script>';
						exit;
					}
				######################## If User Is Department ##########################
				if($row[user_type]=="Department")
					{
						$_SESSION['logged_in'] = true;
						$_SESSION['User_Name'] = $_POST['username'];
						echo '<script language="JavaScript"> window.location.href ="dept_home.php" </script>';
						exit;
					}
			}
	} */
?>