-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodifier.php
More file actions
39 lines (33 loc) · 1.49 KB
/
modifier.php
File metadata and controls
39 lines (33 loc) · 1.49 KB
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
<?php
session_start();
include_once 'autoload.php';
$personneRepository = new PersonneRepository();
$personne = $personneRepository->findByCin($_SESSION['id']);
$nom = ($_POST['nom']=="")? $personne->nom : $_POST['nom'];
$prenom = ($_POST['prenom']=="")? $personne->prenom : $_POST['prenom'];
$age = ($_POST['age']=="")? $personne->age : $_POST['age'];
$section = ($_POST['section']=="")? $personne->section : $_POST['section'];
$cin = ($_POST['cin']=="")? $personne->cin : $_POST['cin'];
$path = $personne->image;
if(isset($_FILES['image']) && ($_FILES['image'])){
if($_FILES['image']['name']!="")
{
$path = "assets/uploads/".uniqid().$_FILES['image']['name'];
copy($_FILES['image']['tmp_name'], $path);
unlink($personne->image);
}
}
include_once 'autoload.php';
$personneRepository = new PersonneRepository();
$personneRepository->Update($_SESSION['id'],$cin,$nom,$prenom,$age,$section,$path);
if(!isset($_SESSION['bdError'])) {
$historyRepository = new HistoriqueRepository();
$date = date('d-m-y h:i:s');
$detail = "Le champ : ".$personne->cin.", ".$personne->nom.", ".$personne->prenom.", ".$personne->age.", ".$personne->age.", ".$personne->image.", | a changé a : ${cin}, ${nom}, ${prenom}, ${age}, ${section}, ${image}";
$historyRepository->ajouthistorique($_SESSION['user'],$date,"modifcation",$cin,$detail);
header('location:home.php');
unset($_SESSION['id']);
}
else{
header('location:modifpage.php');
}