<?php session_start();
if(!empty($_SESSION['user_connect_id']))
{ require('../../config.php');

date_default_timezone_set('Africa/Algiers');
$d_aj=date('Y-m-d H:i:s');

$id_patient=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['id_patient']))) ;

$type_consult=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['type_consult']))) ;
$motif=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['motif']))) ;
if(!empty($_POST['poids'])){
$poids=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['poids']))) ;
}else{
$poids=0;
}
if(!empty($_POST['taille'])){
$taille=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['taille']))) ;
}else{
$taille=0;
}
if(!empty($_POST['temperature'])){
$temperature=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['temperature']))) ;
}else{
$temperature=0;
}
if(!empty($_POST['poids'])){
$perimetre_cranien=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['perimetre_cranien']))) ;
}else{
$perimetre_cranien=0;
}
if(!empty($_POST['frequence_cardiaque'])){
$frequence_cardiaque=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['frequence_cardiaque']))) ;
}else{
$frequence_cardiaque=0;
}
if(!empty($_POST['glycemie'])){
$glycemie=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['glycemie']))) ;
}else{
$glycemie=0;
}


$diagnostic_medical=mysqli_real_escape_string($con,htmlspecialchars(trim($_POST['diagnostic_medical']))) ;

$sql2 = "INSERT INTO consultations (type_consult,motif,poids,taille,temperature,perimetre_cranien,frequence_cardiaque,glycemie,diagnostic_medical,id_patient,date_creation) VALUES 
('$type_consult','$motif','$poids','$taille','$temperature','$perimetre_cranien','$frequence_cardiaque','$glycemie','$diagnostic_medical','$id_patient','$d_aj')";

  if(mysqli_query($con,$sql2)){
  echo 1;
  } else {
echo 0;
 }

    }

?>