public function insert($post)
 {
     extract($post);
     $ip = $_SERVER['REMOTE_ADDR'];
     $verification = DATABASE::DB()->prepare("SELECT * FROM result WHERE ip = :id");
     $verification->bindvalue(':id', $ip, PDO::PARAM_STR);
     $verification->execute();
     $correspondance = $verification->fetch();
     if (!$correspondance) {
         $query = "\n\t\t\tINSERT INTO result (\n\t\t\tip,question_1, question_2, question_3, question_4, question_5, question_6, \n\t\t\tquestion_7, question_8, question_9, question_10_1, question_10_2, question_10_3, \n\t\t\tquestion_11, question_12) \n\t\t\tVALUES (\n\t\t\t:ip,:question_1, :question_2, :question_3, :question_4, :question_5, :question_6, \n\t\t\t:question_7, :question_8, :question_9, :question_10_1, :question_10_2, :question_10_3, \n\t\t\t:question_11, :question_12)";
         $insert = DATABASE::DB()->prepare($query);
         $insert->bindvalue(':ip', $ip, PDO::PARAM_STR);
         $insert->bindvalue(':question_1', $question_1, PDO::PARAM_STR);
         $insert->bindvalue(':question_2', $question_2, PDO::PARAM_STR);
         $insert->bindvalue(':question_3', $question_3, PDO::PARAM_STR);
         $insert->bindvalue(':question_4', $question_4, PDO::PARAM_STR);
         $insert->bindvalue(':question_5', $question_5, PDO::PARAM_STR);
         $insert->bindvalue(':question_6', $question_6, PDO::PARAM_STR);
         $insert->bindvalue(':question_7', $question_7, PDO::PARAM_STR);
         $insert->bindvalue(':question_8', $question_8, PDO::PARAM_STR);
         $insert->bindvalue(':question_9', $question_9, PDO::PARAM_STR);
         $insert->bindvalue(':question_10_1', $question_10_1, PDO::PARAM_STR);
         $insert->bindvalue(':question_10_2', $question_10_2, PDO::PARAM_STR);
         $insert->bindvalue(':question_10_3', $question_10_3, PDO::PARAM_STR);
         $insert->bindvalue(':question_11', $question_11, PDO::PARAM_STR);
         $insert->bindvalue(':question_12', $question_12, PDO::PARAM_STR);
         $insert->execute();
         return $info = "GOOD";
     } else {
         return $info = "ERROR_IP";
     }
 }
Esempio n. 2
0
 public function connect($post)
 {
     extract($post);
     $finalpass = base64_encode(sha1($password, true));
     $select = DATABASE::DB()->prepare("SELECT * FROM users WHERE name = :name AND password = :password");
     $select->bindvalue(':name', $username, PDO::PARAM_STR);
     $select->bindvalue(':password', $finalpass, PDO::PARAM_STR);
     $select->execute();
     $correspondance = $select->fetch();
     if ($correspondance) {
         $_SESSION['login'] = '******';
         $_SESSION['id'] = $correspondance['id'];
         $_SESSION['name'] = $correspondance['name'];
         $_SESSION['nb_survey'] = $correspondance['nb_survey'];
     }
 }
Esempio n. 3
0
 public function add_survey($post)
 {
     extract($post);
     isset($choice_1) ? $choice_1 = $choice_1 : ($choice_1 = '');
     isset($choice_2) ? $choice_2 = $choice_2 : ($choice_2 = '');
     isset($choice_3) ? $choice_3 = $choice_3 : ($choice_3 = '');
     isset($choice_4) ? $choice_4 = $choice_4 : ($choice_4 = '');
     isset($choice_5) ? $choice_5 = $choice_5 : ($choice_5 = '');
     $insert = DATABASE::DB()->prepare("INSERT INTO surveys (id_user, name, description, choice_1, choice_2, choice_3, choice_4, choice_5) VALUES (:id_user, :name, :description, :choice_1, :choice_2, :choice_3, :choice_4, :choice_5)");
     $insert->bindvalue(':id_user', $_SESSION['id'], PDO::PARAM_INT);
     $insert->bindvalue(':name', $name, PDO::PARAM_STR);
     $insert->bindvalue(':description', $description, PDO::PARAM_STR);
     $insert->bindvalue(':choice_1', $choice_1, PDO::PARAM_STR);
     $insert->bindvalue(':choice_2', $choice_2, PDO::PARAM_STR);
     $insert->bindvalue(':choice_3', $choice_3, PDO::PARAM_STR);
     $insert->bindvalue(':choice_4', $choice_4, PDO::PARAM_STR);
     $insert->bindvalue(':choice_5', $choice_5, PDO::PARAM_STR);
     $insert->execute();
 }