<?php
session_start();
function connect(){
$dbc = mysqli_connect("localhost", "bowensta_bowen", "80622BOWen") or die('No server');
	mysqli_select_db($dbc, "bowensta_sshub") or die('No db');
	return $dbc;

}

require '../phpClasses/init.php';

$dbc = connect();
$username = $_POST['user'];
$password =  $_POST['pass'];
$username = strtoupper($username);
$query  = "SELECT * FROM nonacadstaffs WHERE staffsId='$username' AND password='$password'";
$run = mysqli_query($dbc, $query);
$num = mysqli_num_rows($run);
if($num == 1){
    $row = mysqli_fetch_row($run);
    if($row[12] != $unit){
        echo 0;
    }else{
	$_SESSION['staff_session'] = $username;
	echo 1;
    }
}else{
	$query2 = "SELECT * FROM nonacadstaffs WHERE staffsId='$username' AND email='$password' AND password IS NULL";
	$run2 = mysqli_query($dbc, $query2);
	
	$num2 = mysqli_num_rows($run2);

	if($num2 == 1){
		$_SESSION['staff_reg'] = $username;
			echo "Reg";
	}else{
		session_destroy();
		echo 0;
	}
	
	
}


?>