diff --git a/canapEPFL/cible.php b/canapEPFL/cible.php
index b6fb12f569946973132d038eb7775e198060eb15..5c4d095c9657f03956891910e5ed7b03365c62e4 100644
--- a/canapEPFL/cible.php
+++ b/canapEPFL/cible.php
@@ -39,7 +39,6 @@
         // $_SESSION['formError'] = false;
         // unset($_SESSION);
         // include("templates/confirmationText.php");
-        echo "done";
       } else {
         $_SESSION['formError'] = true;
         $_SESSION['postedForm'] = $_POST;
diff --git a/canapEPFL/helpers.php b/canapEPFL/helpers.php
index 6ecdb4cbe0fcc687ff420bede4f2fb008ff433bc..29ba5af3b890d4772c870be02da7831e958b1140 100644
--- a/canapEPFL/helpers.php
+++ b/canapEPFL/helpers.php
@@ -64,6 +64,51 @@ function uploadAllFiles($pathAnnexes, $postedFiles, $candidateData){
 function insertDataIntoDB ($pdo, $candidateData) {
   echo "<pre>";
   print_r($candidateData);
+  $id = insertPersonalInfos($pdo, $candidateData);
+
+  insertResponsibles($pdo, $candidateData->representants, $id);
+
+  // create reponsable then
+  // responsables
+  // $pdo->bindParam(':fk_applicant_main_responsible', $candidateData->$job, PDO::PARAM_STR);
+  // $pdo->bindParam(':fk_applicant_sec_responsible', $candidateData->$job, PDO::PARAM_STR);
+
+  // files
+}
+
+function insertResponsibles ($pdo, $representants, $applicantId) {
+  $addedRepIds = [];
+
+  // insert responsibles
+  $sqlreq = "INSERT INTO responsible (responsible_gender, responsible_name, responsible_fsname, responsible_street, responsible_npa, responsible_phone)
+    VALUES (:responsible_gender, :responsible_name, :responsible_fsname, :responsible_street, :responsible_npa, :responsible_phone)";
+  foreach ($representants as $rep) {
+    if ($rep['nom'] != '') {
+      $query = $pdo->prepare($sqlreq);
+      $query->bindParam(':responsible_gender', $rep['genre'], PDO::PARAM_STR);
+      $query->bindParam(':responsible_name', $rep['nom'], PDO::PARAM_STR);
+      $query->bindParam(':responsible_fsname', $rep['prenom'], PDO::PARAM_STR);
+      $query->bindParam(':responsible_street', $rep['addresse']['rue'], PDO::PARAM_STR);
+      $query->bindParam(':responsible_npa', $rep['addresse']['NPA'], PDO::PARAM_STR);
+      $query->bindParam(':responsible_phone', $rep['telephone'], PDO::PARAM_STR);
+      $query->execute();
+      array_push($addedRepIds, $pdo->lastInsertId());
+    }
+  }
+
+  // link responsibles
+  $main_rep_id = $addedRepIds[0] ? $addedRepIds[0] : null;
+  $sec_rep_id = $addedRepIds[1] ? $addedRepIds[1] : null;
+
+  $sqlreq = "UPDATE applicant SET fk_applicant_main_responsible=:fk_applicant_main_responsible, fk_applicant_sec_responsible=:fk_applicant_sec_responsible WHERE applicant_id=:applicant_id";
+  $query = $pdo->prepare($sqlreq);
+  $query->bindParam(':fk_applicant_main_responsible', $main_rep_id, PDO::PARAM_INT);
+  $query->bindParam(':fk_applicant_sec_responsible', $sec_rep_id, PDO::PARAM_INT);
+  $query->bindParam(':applicant_id', $applicantId, PDO::PARAM_INT);
+  $query->execute();
+}
+
+function insertPersonalInfos ($pdo, $candidateData) {
   $sqlreq = "INSERT INTO applicant
 	(applicant_formation, applicant_it_section, applicant_formation_location, applicant_maturity, applicant_gender, applicant_name, applicant_fsname, applicant_address_street, applicant_address_npa, applicant_home_phone, applicant_personal_phone, applicant_mail, applicant_birthdate, applicant_origin, applicant_nationality, applicant_foreign_authorization, applicant_avs, applicant_main_language, applicant_speaks_french, applicant_speaks_german, applicant_speaks_english, applicant_speaks_other, applicant_has_majority, applicant_scolarity_end, applicant_already_applicant, applicant_already_applicant_year, applicant_application_date, applicant_application_status, fk_applicant_main_responsible, fk_applicant_sec_responsible)
   VALUES (:applicant_formation, :applicant_it_section, :applicant_formation_location, :applicant_maturity, :applicant_gender, :applicant_name, :applicant_fsname, :applicant_address_street, :applicant_address_npa, :applicant_home_phone, :applicant_personal_phone, :applicant_mail, :applicant_birthdate, :applicant_origin, :applicant_nationality, :applicant_foreign_authorization, :applicant_avs, :applicant_main_language, :applicant_speaks_french, :applicant_speaks_german, :applicant_speaks_english, :applicant_speaks_other, :applicant_has_majority, :applicant_scolarity_end, :applicant_already_applicant, :applicant_already_applicant_year, NOW(), 'new', null, null)";
@@ -99,18 +144,7 @@ function insertDataIntoDB ($pdo, $candidateData) {
   $query->bindParam(':applicant_already_applicant', $candidateData->dejaCandidat, PDO::PARAM_BOOL);
   $query->bindParam(':applicant_already_applicant_year', $candidateData->anneeCandidature, PDO::PARAM_STR);
 
-  try {
-    $query->execute();
-  } catch(Exception $e) {
-    echo $e;
-  }
-
-
-  // create reponsable then
-  // responsables
-  // $pdo->bindParam(':fk_applicant_main_responsible', $candidateData->$job, PDO::PARAM_STR);
-  // $pdo->bindParam(':fk_applicant_sec_responsible', $candidateData->$job, PDO::PARAM_STR);
-
-  // files
+  $query->execute();
+  return $pdo->lastInsertId();
 }
 ?>
\ No newline at end of file