Facebook
From Bistre Partdridge, 1 Week ago, written in PHP.
Embed
Download Paste or View Raw
Hits: 42
  1. if (isset($_POST['receiver']) && isset($_POST['sender']) && isset($_POST['date'])&& isset($_POST['id'])  && isset($_POST['words']) ) {
  2.    
  3.     $receiver = $_POST['receiver'];
  4.     $sender = $_POST['sender'];
  5.     $date = $_POST['date'];
  6.     $id= $_POST['id'];
  7.  
  8.  
  9.     $result = $con->query("INSERT INTO message_info(receiver, sender, date, id) VALUES('$receiver', '$sender', '$date', '$id')");
  10.  
  11.     if ($result) {
  12.                 foreach($_POST['words'] as $word){
  13.             $resultWordsId = $con->query("SELECT id FROM not_allowed_words where word = '". $word ."'");
  14.                 if($rowIdWord = $resultWordsId->fetch_assoc()) {
  15.                     $result2 = $con->query("INSERT INTO message_words(id, id_word) VALUES('".$id."', '".$rowIdWord['id']."')");
  16.                 }
  17.                
  18.  
  19.                 }
  20.         $response["success"] = 1;
  21.         $response["message"] = "Product successfully created.";
  22.  
  23.         echo json_encode($response);
  24.     } else {
  25.  
  26.         $response["success"] = 0;
  27.         $response["message"] = "Oops! An error occurred.";
  28.  
  29.         echo json_encode($response);