1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
   |                                 <?php echo $reponse; ?>
                                <?php if(isset($_COOKIE["pseudo"])) { ?>
                                <?php                          
                                $db_link =      mysql_connect("...", "...", "...");
                                mysql_select_db("...", $db_link);
 
                                if(isset($_POST)) {
                                        foreach($_POST as $k => $v) {
                                                $_POST[$k] = trim(htmlspecialchars($v)) ;
                                        }
                                }
                                if(isset($_GET)) {
                                        foreach($_GET as $k => $v) {
                                                $_GET[$k] = trim(htmlspecialchars($v)) ;
                                        }
                                }
                                if(isset($_POST['send'])) {
                                        if($_POST['send'] == 'new') {
                                        $sql = "INSERT INTO wa_news (auteur,date,titre,news) values ('".$_COOKIE['pseudo_prenom']." ".$_COOKIE['pseudo_nom']."',now(),'".$_POST['titre']."','".$_POST['news']."')";
                                        }
                                        elseif($_POST['send'] == 'update') {
                                        $sql = 'update wa_news set titre = "'.$_POST['titre'].'", auteur =
                                        "'.$_COOKIE['pseudo_prenom'].' '.$_COOKIE['pseudo_nom'].'", news = "'.$_POST['news'].'", date =
                                        "'.$_POST['date'].'" WHERE newsId = "'.$_POST['newsId'].'"';
                                        }
                                        mysql_query($sql,$db_link) or die(mysql_error());
                                }
                                if(isset($_GET['delete']) and is_numeric($_GET['delete'])) {
                                   mysql_query("delete from wa_news where newsId = \"".$_GET['delete']."\"",$db_link);
                                }
                                if(isset($_GET['edit']) and is_numeric($_GET['edit'])) {
                                        $Id = $_GET['edit'] ;
                                        $sql = 'SELECT * FROM wa_news WHERE newsId="'.$Id.'" LIMIT 1' ;
                                        $rc = mysql_query($sql,$db_link);
                                        while($data = mysql_fetch_array($rc)) { ?>
                                        <div class="bloc_03">
                                                <h1 class="separate">Modifier l'article</h1>
                                                <form action="home.php" method="post">
                                                        <table>
                                                                <tr><td class="titre-news">Titre :</td></tr>
                                                                <tr><td><input type="text" class="news-titre" name="titre" value="<?php echo htmlentities($data['titre']); ?>" /></td></tr>
                                                                <tr><td class="titre-news">Article :</td></tr>
                                                                <tr><td><textarea name="news" class="news-article"><?php echo htmlentities($data['news']); ?></textarea></td></tr>
                                                        </table>
                                                        <input type="hidden" name="newsId" value="<?php echo $_GET['edit']; ?>" />
                                                        <input type="hidden" name="send" value="update" />
                                                        <input type="submit" src="" class="submit-news" value="" />
                                                </form>
                                        </div>
                                        <?php }
                                }
                                else { ?>
                                        <div class="bloc_03">
                                                <h1 class="separate">Poster un article</h1>
                                                <form action="" method="post" onsubmit="maFonctionAjax(this.titre.value,this.news.value);return false">
                                                        <table>
                                                                <tr><td class="titre-news">Titre :</td></tr>
                                                                <tr><td><input type="text" autocomplete="off" class="news-titre" name="titre" /></td></tr>
                                                                <tr><td class="titre-news">Article :</td></tr>
                                                                <tr><td><textarea name="news" autocomplete="off" class="news-article" value="Exprimez-vous..." onfocus="if (this.value==this.defaultValue) this.value = ''" onblur="if (this.value=='') this.value = this.defaultValue">Exprimez-vous...</textarea></td></tr>
                                                        </table>
                                                        <input type="hidden" name="send" value="new" />
                                                        <input type="submit" class="submit-news" value="" />
                                                </form>
                                                <div id="msg"></div>
                                        </div>
                                        <?php
                                        $sql = 'SELECT * FROM wa_news ORDER BY newsId DESC' ;
                                        $rc = mysql_query($sql,$db_link);
                                        while($data = mysql_fetch_array($rc)) {
                                        $data['date'] = date('d/m/Y');
                                        ?>
                                        <div class="bloc_03">
                                                <h1 class="separate"><?php echo $data['titre']; ?></h1>
                                                Le <?php echo $data['date']; ?> par <?php echo $data['auteur']; ?><br />
                                                <?php echo $data['news']; ?>
                                                <br />=> <a href="?delete=<?php echo $data['newsId']; ?>">Supprimer</a> -
                                                <a href="?edit=<?php echo $data['newsId']; ?>">Editer</a>
                                        </div>
                                        <?php } } mysql_close(); ?>
                                <?php } else { ?>
                                <div class="bloc_03">
                                        <h1 class="separate">Actualités à la Une</h1>
                                </div>
                                <?php } ?> | 
Partager