diff --git a/canapEPFL/helpers.php b/canapEPFL/helpers.php index 7f0a781ba59a2140f947753c0a78e17a9dd99536..75482e53a689ccd17f8197c8c992bc65cb47aafa 100644 --- a/canapEPFL/helpers.php +++ b/canapEPFL/helpers.php @@ -293,16 +293,17 @@ function deletePostulation ($pdo, $id, $sciper, $rep1, $rep2) { foreach ($filesToRemove as $key => $file) { unlink($file['file_path']); } + // delete applicant folder $dir = dirname($file['file_path']); rmdir($dir); - // delete files (DB only) + // delete files from DB $sqlreq = "DELETE FROM file WHERE fk_applicant_id=:id"; $query = $pdo->prepare($sqlreq); $query->bindParam(':id', $id, PDO::PARAM_STR); $query->execute(); - echo "delete :$id"; + // delete applicant personal data $sqlreq = "DELETE FROM applicant WHERE applicant_id=:id"; $query = $pdo->prepare($sqlreq); $query->bindParam(':id', $id, PDO::PARAM_STR); @@ -484,8 +485,8 @@ function updatePostulation ($pdo, $posted_data) { $file_data = getOneFile($pdo, $file['id'], $posted_data->id); $extension = strtolower("." . pathinfo($file['name'])['extension']); $filename = $key . $extension; - $oldpath = $file_data['file_path']; $path = preg_replace('/\\.[^.\\s]{3,4}$/', '', $file_data['file_path']) . $extension; + unlink($file_data['file_path']); if (move_uploaded_file($file['tmp_name'], $path)) { // success, update db @@ -495,11 +496,8 @@ function updatePostulation ($pdo, $posted_data) { $query->bindParam(':file_name', $filename, PDO::PARAM_STR); $query->bindParam(':file_id', $file_data['file_id'], PDO::PARAM_STR); $query->execute(); - // TODO: check if working - unlink($path); } } -// header('Location: viewpostulation.php'); } #endregion ?> \ No newline at end of file diff --git a/canapEPFL/templates/head.php b/canapEPFL/templates/head.php index 1639fee1e890710af5bd45e719291deb740c5fa5..1169763e9f74a6e079bc1f4715b99e895e93022a 100644 --- a/canapEPFL/templates/head.php +++ b/canapEPFL/templates/head.php @@ -23,8 +23,8 @@ <?php ini_set("display_errors", 0); error_reporting(0); - // ini_set("display_errors", 1); - // error_reporting(E_ALL); + ini_set("display_errors", 1); + error_reporting(E_ALL); require_once('configs/config.php'); require('configs/db.php'); if (!isset($_SESSION)) { session_start(); }