<?php
@session_start();
include("config.php");
error_reporting(0);


$branch=$_POST['branch']; 


// To protect MySQL injection (more detail about MySQL injection)
$branch = stripslashes($branch);


	

    $sql="SELECT * FROM login_admin WHERE branch='$branch'"; 
$result=mysql_query($sql);
 $row = mysql_fetch_array($result); 
// Mysql_num_row is counting table row
$count=mysql_num_rows($result);

// If result matched $myusername and $mypassword, table row must be 1 row
//echo $count; exit;
if($count==1){

// Register $myusername, $mypassword and redirect to file "login_success.php"

$_SESSION['branch']=stripslashes($row['branch']); 


header("location:welcome.php?flag=dn");
}
else {
header("location:dashboard.php?flag=invalid");
exit;
}
   
?>