Esempio n. 1
0
         $data["uid"] = "The user does not exist in the database!";
         echo json_encode($data);
     }
 } else {
     if ($mode == 'addMessage') {
         /**
          * According to the logic of the Android program
          * at this point we already have the topic_id
          * and the posted_by that will be set when the program opens
          * by calling the function getUserDetails($name)
          */
         if (isset($_POST['content']) && $_POST['post_topic'] && $_POST['posted_by'] && $_POST['content'] != '' && $_POST['post_topic'] != '' && $_POST['posted_by'] != '') {
             $content = $_POST['content'];
             $post_topic = $_POST['post_topic'];
             $posted_by = $_POST['posted_by'];
             $success = $database->insertMessage($content, $post_topic, $posted_by);
             if ($success) {
                 $data["success"] = 1;
                 $data["error"] = 0;
                 $data["message"] = "A new message was inserted in the database!";
                 echo json_encode($data);
             } else {
                 $data["success"] = 0;
                 $data["error"] = 1;
                 $data["error_message"] = "It was not possible to insert the message in the database!";
                 echo json_encode($data);
             }
         }
     } else {
         if ($mode == 'deleteTopic') {
             if (isset($_POST['topic_id']) && $_POST['topic_id'] != '' && isset($_POST['user_name']) && $_POST['user_name'] != '') {