diff options
author | citizenz7 <citizenz7@protonmail.com> | 2017-04-20 18:50:55 +0200 |
---|---|---|
committer | citizenz7 <citizenz7@protonmail.com> | 2017-04-20 18:50:55 +0200 |
commit | 5fd9fa480f302902328b81f912dd67ce378284f8 (patch) | |
tree | 66234843ae2857fda12442e4f7577c527d48977c /Html/messages_repondre.php | |
parent | ebe731862c7c741171138b1083906f391fc35aff (diff) | |
download | freetorrent-5fd9fa480f302902328b81f912dd67ce378284f8.tar.xz freetorrent-5fd9fa480f302902328b81f912dd67ce378284f8.zip |
V.1.4.6
Diffstat (limited to 'Html/messages_repondre.php')
-rw-r--r-- | Html/messages_repondre.php | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/Html/messages_repondre.php b/Html/messages_repondre.php new file mode 100644 index 0000000..8df516b --- /dev/null +++ b/Html/messages_repondre.php @@ -0,0 +1,96 @@ +<?php + +require_once('includes/config.php'); + +if(!$user->is_logged_in()) { + header('Location: login.php'); +} + +$pagetitle = 'Messagerie'; + +include_once('includes/header.php'); + +?> + +<body> + +<div id="container"> + + <?php + include_once('includes/header-logo.php'); + include_once('includes/nav.php'); + ?> + + <div id="body"> + + <div id="content"> + +<?php + +// on teste si le formulaire a bien été soumis +if (isset($_POST['go']) && $_POST['go'] == 'Envoyer') { + if (empty($_POST['destinataire']) || empty($_POST['titre']) || empty($_POST['message'])) { + $error[] = 'Au moins un des champs est vide.'; + } + else { + + // si tout a été bien rempli, on insère le message dans notre table SQL + $stmt = $db->prepare('INSERT INTO blog_messages (messages_id_expediteur,messages_id_destinataire,messages_date,messages_titre,messages_message) VALUES (:messages_id_expediteur,:messages_id_destinataire,:messages_date,:messages_titre,:messages_message)'); + $stmt->execute(array( + ':messages_id_expediteur' => html($_SESSION['userid']), + ':messages_id_destinataire' => html($_POST['id_destinataire']), + ':messages_date' => date("Y-m-d H:i:s"), + ':messages_titre' => html($_POST['titre']), + ':messages_message' => html($_POST['message']) + )); + + header('Location: '.SITEURL.'/admin/profil.php?membre='.html($_SESSION['username']).'&message=ok'); + //$stmt->closeCursor(); + //exit(); + } +} + +//S'il y a des erreurs, on les affiche +if(isset($error)){ + foreach($error as $error){ + echo '<div class="alert-msg rnd8 error">ERREUR : '.$error.'</div>'; + } +} +?> + +<?php + +$desti = $db->prepare('SELECT * FROM blog_messages LEFT JOIN blog_members ON blog_members.memberID = blog_messages.messages_id_expediteur WHERE messages_id = :message_id'); +$desti->execute(array( + ':message_id' => html($_GET['id_message']) +)); +$data = $desti->fetch(); +?> + +<form action="messages_repondre.php" method="post"> + <input type="hidden" name="id_destinataire" value="<?php echo html($_GET['id_destinataire']); ?>"> + Répondre à : <input type="text" name="destinataire" value="<?php echo html(trim($data['username'])); ?>"> + <br /><br /> + Titre : <input type="text" name="titre" size="70" value="Re: <?php echo html(trim($data['messages_titre'])); ?>"> + <br /><br /> + Message : <textarea name="message" style="height:250px;width:900px;"> + [quote]<?php echo trim($data['messages_message']); ?>[/quote] + + </textarea> + <input type="submit" name="go" value="Envoyer"> +</form> + + </div> + + <?php require('sidebar.php'); ?> + + <div class="clear"></div> + </div> +</div> + +<div id="footer"> + <?php require('includes/footer.php'); ?> +</div> + +</body> +</html> |