function envoyer_message($destinataire, $texte) { //var globales global $table_conversations, $id; $binome = new Binome($destinataire); $conversation = null; //recherche de conversation courante $sql = "SELECT * FROM " . $table_conversations . " WHERE user1 = '" . $binome->nom1 . "' AND user2 = '" . $binome->nom2 . "' AND session_1 = '" . $binome->session1 . "' AND session_2 = '" . $binome->session2 . "';"; $resultat = mysql_query($sql); if (!$resultat || mysql_num_rows($resultat) == 0) { //on cree une nouvelle conversation $conversation = create_conversation($destinataire); } else { $conversation = mysql_result($resultat, 0, 'id_conversation'); } echo "envoi"; //nouveau message create_message($conversation, $destinataire, $id, $texte); }
} include "funkcja.php"; $user_ids = fetch_user_ids($user_names); if (count($user_ids) !== count($user_names)) { $errors[] = 'Uzytkownicy nie moga zostac znalezieni ' . implode(', ', array_diff($user_names, array_keys($user_ids))); } } } if (empty($_POST['temat'])) { $errors[] = 'Temat nie moze byc pusty'; } if (empty($_POST['body'])) { $errors[] = 'Musisz cos napisac, nie można wysłać pustej wiadomości'; } if (empty($errors)) { create_conversation(array_unique($user_ids), $_POST['temat'], $_POST['body']); } } if (isset($errors)) { if (empty($errors)) { echo '<div class ="alert alert-success">Twoja Wiadomosc została wysłana! <a href="Inbox.php">Wróc do skrzynki</a></div>'; } else { foreach ($errors as $error) { echo '<div class="alert alert-danger">', $error, '</div>'; } } } ?> <div><a href="Inbox.php" class="hvr-bounce-in" style="text-decorations:none; color:inherit; margin: 20px;" ><i class="fa fa-inbox fa-5x"></i><i class="fa fa-reply"></i> Wróc do skrzynki</a></div> <label for="do"> Do </label>