<?php include 'topmost.php';
if(isset($_POST['email'])){
$user= $_POST['email']; // collected Email
$password = $_POST['myPass']; $pass = hash('sha256',$password); //hashed password
$finduser = mysqli_query($dbconn,"SELECT * FROM login where username='$user' and password ='$pass' ");
if(mysqli_num_rows($finduser)==1){
	$rows = mysqli_fetch_assoc($finduser);
QueryDB("UPDATE login SET lastlog=curlog, curlog='".time()."' WHERE username='$user'  ");
	$pos = $rows['position'];
	if($pos==1){
		//sales
		$_SESSION['sales']=$user;
		echo 3;
	}else{
		//if ==2 - admin'
		$_SESSION['admin']=$user;
		echo 4;
	}
	
	
}else {
	echo 2;
}

}


//
if(isset($_POST['selected_form_cost'])){ $id =$_POST['selected_form_cost'];
$findCost = QueryDB("SELECT reg_cost FROM courses where id='$id' ");
$row = $findCost->fetch(PDO::FETCH_ASSOC); 
echo $row['reg_cost'];

}


//show Product Info
if(isset($_POST['getProductInfo'])){ $selProd = getProduct($_POST['getProductInfo']);
$html =  '<div class="row"><div class="col-md-6">Color:<b class="text-danger">'.$colored_by[$selProd['color']].'</b></div> <div class="col-md-6"> Size <b class="text-danger">'.$sized_by[$selProd['size']].' </b></div><div class="col-md-12"> Brand:  <b class="text-danger">'.$brand[$selProd['brand']].' </b></div><div class="col-md-12"> Company: <b class="text-danger">'.$company[$selProd['company']].' </b></div>';
echo $html;
}


?>