<?php
session_start();
require('45789417/ref4780.php');
if (!isset($_SESSION['userid'])) {
  echo "<script language='Javascript'> location.href='login.php';</script>";
    exit();
  };
  if ($_SESSION['type_user_live'] == "Paciente") {
   	echo "<script type='text/javascript'>  
	window.location='paci_virtual/index.php';
	</script>";
    }
?>
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8"> 
<title>Historia Clínica, Clínica Los Robles</title>
</head>
<body>
<?php
$id = $_GET['id'];
/*
$sql = "DELETE FROM hc_paciente, hc_alimentacion, hc_antecedentes, hc_ask_control, hc_control0, hc_control1, hc_controlpeso, hc_habitos, hc_sintomas, dieta WHERE id='$id'";
$result=mysqli_query($sql);
*/
$tables = array("hc_paciente","hc_alimentacion","hc_antecedentes","hc_ask_control","hc_control0","hc_control1","hc_controlpeso","hc_habitos","hc_sintomas","dieta");
foreach($tables as $table) {
  $sql = "DELETE FROM $table WHERE id='$id'";
  $result=mysqli_query($sql);
}

// if successfully deleted
if($result){
	echo "<script language='Javascript'> location.href='home.php?delpaciente=1';</script>";
} else {
	echo "ERROR";
}
mysqli_close();

?>
</body>
</html>