1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
| <?php
// On démarre la session AVANT d'écrire du code HTML
if(isset($_SESSION)) {
//si il y a un session existante donc si la session est ouverte
} else {session_start();}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr">
<head>
<title> Create et Save Reports</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel= "stylesheet" type="text/css" href="design.css" />
</head>
<body>
<?php
//verifier que la personne est connecté
if (isset ($_SESSION['verification']) AND $_SESSION['verification']=='valide')
{
if (isset ($_POST['numreport'] ) AND isset ($_POST['dateexamen']) AND isset($_POST['patientname'])
AND isset($_POST['patientage']) AND isset($_POST['sex']) AND isset($_POST['localisation']) AND isset($_POST['description']) AND isset($_POST['resultat'])
AND !empty($_POST['numreport']) AND !empty($_POST['dateexamen']) AND !empty($_POST['patientname']) AND !empty($_POST['patientage'])
AND !empty($_POST['sex']) AND !empty($_POST['localisation']) AND !empty($_POST['description']) AND !empty($_POST['resultat'])
AND preg_match ("#^[0-9]{0,3}$#",$_POST['patientage']) AND preg_match ("#^[0-9]{4}-[0-1][0-9]-[0-3][0-9]$#",$_POST['dateexamen']))
{
try
{
// On se connecte à MySQL
$pdo_options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_EXCEPTION;
$bdd = new PDO('mysql:host=localhost;dbname=easyreport', 'root', '', $pdo_options);
// recuperer des infos de $_post met des ? et remplace apres!
// Insertion du message à l'aide d'une requête préparée
$req = $bdd->prepare('INSERT INTO model(idmodel,localisation, description, savemodel)VALUES("",?, ?, ?)');
$req->execute(array($_POST['localisation'], $_POST['description'], $_POST['savemodel']));
$idprovisoire = $bdd->lastInsertId();
$req = $bdd->prepare('INSERT INTO rapport(daterapport, numerorapport, nompatient, agepatient, typeage, numeropatient, sexpatient, numerochambre,
provenancemedical, resultatexamen , idmodel, iddocteur, iddirecteur )VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 0)');
$req->execute(array($_POST['dateexamen'], $_POST['numreport'],$_POST['patientname'],$_POST['patientage'] ,$_POST['agebis'] ,$_POST['patientnumber'],
$_POST['sex'],$_POST['roomnumber'],$_POST['medialdepartement'],$_POST['resultat'],$idprovisoire, $_SESSION['identifiant']));
?>
<form method="post" action="choixmenu.php">
<p>
<input class="boutonbis" type="submit" name="choixmenu" value=" The data have been saved!" />
</p>
</form>
<?php
}
catch(Exception $e)
{
?>
<form method="post" action="createreport.php">
<p>
<input class="boutonbis" type="submit" name="retouracreatereport" value=" Error in data recording try again please." />
</p>
</form>
<?php
}
}
else
{
?>
<form method="post" action="createreport.php">
<p>
<input class="boutonbis" type="submit" name="retouracreatereport" value=" A mistake or a required field were not filled properly, please correct it!" />
<input type="hidden" name="numreport" id="numreport" value="<?php if(isset($_POST['numreport']) && $_POST['numreport']!="" ) echo $_POST['numreport'];?>" />
<input type="hidden" name="dateexamen" id="dateexamen" value="<?php if(isset($_POST['dateexamen']) && $_POST['dateexamen']!="" ) echo $_POST['dateexamen'];?>" />
<input type="hidden" name="patientname" id="patientname" value="<?php if(isset($_POST['patientname']) && $_POST['patientname']!="" ) echo $_POST['patientname'];?>" />
<input type="hidden" name="patientnumber" id="patientnumber" value="<?php if(isset($_POST['patientnumber']) && $_POST['patientnumber']!="" ) echo $_POST['patientnumber'];?>" />
<input type="hidden" name="patientage" id="patientage" value="<?php if(isset($_POST['patientage']) && $_POST['patientage']!="" ) echo $_POST['patientage'];?>"/>
<input type="hidden" name="roomnumber" id="roomnumber" value="<?php if(isset($_POST['roomnumber']) && $_POST['roomnumber']!="" ) echo $_POST['roomnumber'];?>"/>
<input type="hidden" name="medialdepartement" id="medialdepartement" value="<?php if(isset($_POST['medialdepartement']) && $_POST['medialdepartement']!="" ) echo $_POST['medialdepartement'];?>"/>
<input type="hidden" name ="description" id="description" value=" <?php if(isset($_POST['description']) && $_POST['description']!="" ) {echo $_POST['description'];} else { echo 'Write here the exam description' ;} ?>" />
<input type="hidden" name="resultat" id="resultat" value="<?php if(isset($_POST['resultat']) && $_POST['resultat']!="" ) {echo $_POST['resultat'];} else { echo 'Write here the results' ;} ?>" />
<input type="hidden" name="localisation" id="localisation" value="<?php if(isset($_POST['localisation']) && $_POST['localisation']!="" ) echo $_POST['localisation']; ?>" />
</p>
</form>
<?php
}
}
else
// si pas connecté
{
include("index.php");
}
?>
</body>
</html> |