| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <?php
- if(core::getPost("id") == "add"){
-
- db::query("INSERT INTO " . DB_T_LOTTERY . " (md5, titre, description, id_user) VALUES (:md5, :titre, :description, :id_user)");
- db::bind(':md5', md5(time().rand(1000000000, 9999999999)));
- db::bind(':titre', core::getPost("titre"));
- db::bind(':description', core::getPost("description"));
- db::bind(':id_user', session::getId());
-
- try {
- db::execute();
- alert::recSuccess("Le tirage au sort a bien été créé");
- } catch (Exception $ex) {
- alert::recError("Erreur lors de l'enregistrement du tirage au sort");
- header("Location: /add-lottery.html");
- exit();
- }
-
- header("Location: /lottery-" . lottery::lastLottery().".html");
- exit();
-
- } else {
-
- db::query("UPDATE " . DB_T_LOTTERY . " SET "
- . "titre = :titre, "
- . "description = :description, "
- . "sortDate = :sortDate, "
- . "id_user = :id_user "
- . "WHERE id = :id");
-
- db::bind(':titre', core::getPost("titre"));
- db::bind(':description', core::getPost("description"));
- db::bind(':sortDate', core::getPost("sortDate"));
- db::bind(':id_user', session::getId());
- db::bind(':id', core::getPost("id"));
-
- try {
- db::execute();
- alert::recSuccess("Le tirage au sort a bien été modifié");
- } catch (Exception $ex) {
- alert::recError("Erreur lors de la modification le tirage au sort");
- header("Location: /lottery-" . core::getPost("id").".html");
- exit();
- }
- header("Location: /lottery-" . core::getPost("id").".html");
- exit();
- }
|