<?php
session_start();
ob_start();
if (isset($_SESSION['us_name']) AND isset($_SESSION['us_password'])){
		
		require_once("db_connect.php");
		$id=htmlspecialchars($_GET["id"]);
		$url=htmlspecialchars($_GET["url"]);

		$sql= "DELETE FROM sensor WHERE id=$id";
		if ($conn->query($sql) === TRUE) {
		    $_SESSION['error']="Smazáno";
		    unlink($url); 
		    header("Location: user.php");
		} else {
		    $_SESSION['error']="Chyba";
		    header("Location: user.php");
		}

}else{
  header ("Location: index.php"); 
}


ob_end_flush();
?>