<?php
session_start();
error_reporting(E_ALL);

include "../dbconfig.php";
        ob_start();
 //print_r($_POST);
 
	     if(!empty($_POST['user_name'])&&($_POST['pin']))
		{
                
				
				$user_name = $con->real_escape_string($_POST['user_name']);
                $password = $con->real_escape_string($_POST['pin']);
		 		$sql = "SELECT `user_name`, `user_role` FROM `users` WHERE `user_name` = '$user_name' AND password = '$password' ";
		 	    //echo $sql;
				//exit;
				if(!mysqli_query($con,$sql))
				{
					die('Error'.mysqli_error($con,$sql));
					
					}
		 		//exit;
                 $res = mysqli_query($con,$sql);
                  if(mysqli_num_rows($res)>0)
                  {
                      
					  $user=mysqli_fetch_assoc($res);
					  $role=$user['user_role'];
					  
					  $_SESSION['user_name']=$user['user_name'];
				//	  echo "seesion id ".$_SESSION['user_id'];
					 //exit;
					echo $role;
					  
				}//elseif($role=='Student')
                  else
				{	
                          
						  echo "Failed";
						  // header("Location: ../re_login.html");
				}
			
	      }
		  
	  
	  
?>