Skip to content
Extraits de code Groupes Projets
Sélectionner une révision Git
  • 7142fe0f84882867703a90ce525fb3f06af2c1e7
  • master par défaut protégée
2 résultats

newtopics.php

Blame
  • Bifurcation depuis Nassim YAICI / projet_web
    Le projet source a une visibilité limitée.
    newtopics.php 4,87 Kio
    <?php
    session_start();
    require_once"fonction.php";
    require_once"./class/newtopics.class.php";
    $bdd=bdd();
    
    if (isset($_POST['name'], $_POST['content'])) {
      $name=$_POST['name'];
      $content = $_POST['content'];
      $newtop = new newtopics($name, $content);
      $verif = $newtop->verif();
    
      if ($verif =="ok") {
        if($newtop->insert()){
          header("Location: accueil.php");
        }
      }
      else
      {
        $erreur = $verif;
      }
    }
    
    ?>
    
    <!DOCTYPE html>
    <html lang="en">
    <head>
      <title>Com-Ensiie</title>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <link rel="stylesheet" href="./bootstrap/css/bootstrap.css">
      <link rel="stylesheet" href="./bootstrap/css/mystyle.css">
      <script src="./script.js"></script>
    </head>
    <body>
      <div class="container-fluid">
      <div class="jumbotron">
          <h1><span style="color: white">Com-Ensiie</span></h1>
    <?php
    if(isset($_SESSION['pseudo'])){
      $pseudo=$_SESSION['pseudo'];
    ?>
           </div>
           <button type="button" class="btn btn-success btn-right" onclick="location.href='./deconnexion.php'" >Deconnexion</button>
           <button type="button" class="btn btn-success btn-right" onclick="location.href='./edit.php'" >Edit</button>
           <button type="button" class="btn btn-success btn-right" onclick="location.href='./newtopics.php'" >Nouveau sujet</button>
           <label for="hello"><?php echo "Vous êtes connectés entant que : $pseudo";?></label>
           </div>
    <?php
    }
    else
    {
    ?>
      </div>
        <button type="button" class="btn btn-success btn-right" onclick="location.href='./login.php'" >Log In</button>
        <button type="button" class="btn btn-success btn-right" onclick="location.href='./register.php'">Register</button>
      </div>
    <?php
    }
    ?>
      <nav class="navbar navbar-inverse">
        <div class="navbar-header">
          <a class="navbar-brand" href="./accueil.php">Com-Ensiie</a>
        </div>
                <?php
                  $dn2 = pg_query("SELECT * FROM keys ORDER BY name asc");
                  while($reponse=pg_fetch_assoc($dn2))
                {
                ?>
                  <div class="navbar-header">
                    <ul class="nav navbar-nav">
                    <li class="dropdown active"><a href="./topiclist.php?category=<?php echo $reponse['name']; ?>"><?php echo $reponse['name']; ?></a></li>
                    </ul>
                  </div>            
                <?php
                }
                ?>
      </nav>
    </div>
        
    
    
    <div class="container-fluid text-center">    
      <div class="row content">
        <div class="col-sm-2 sidenav">
          <?php
          if(isset($_SESSION['su'])){
          if ($_SESSION['su']=='t') {
          ?>
          <div>
          <button type="button" class="btn btn-info btn-right" onclick="location.href='./adminEdit.php'" >Edit users</button><br><br>
        </div>
          <div>
          <button type="button" class="btn btn-info btn-right" onclick="location.href='./adminEditTopics.php'" >Edit toppics</button>
        </div>
          <?php
        }}
          ?>
        </div>
        <div class="col-lg-8 text-left"> 
          <br>
            <form class="form-horizontal" role="form" method="post" action="./newtopics.php">
              <div class="row topic-create">
                <div class="col-sm-2 text-right">
                  <label class="col-sm-2 text-right">Catégorie</label>
                </div>
                  <div class="col-sm-10">
                  <select class="selectpicker" name="category">
                        <?php
                          $dn2 = pg_query("SELECT * FROM keys ORDER BY name asc");
                          while($reponse=pg_fetch_assoc($dn2))
                          {
                        ?>
                          <option id="cat"><?php echo $reponse['name']; ?></a></li>
                    
                        <?php
                          }
                        ?>
                        
                  </select>
                </div>
              </div>
              <div class="row topic-create">
                   <label class="col-sm-2 text-right">Titre</label>
                   <div class="col-sm-10">
                      <input class="form-control" id="focusedInput" type="text" name="name" placeholder ="Le titre ..."required
                      aria-required="true" pattern="^([- \w\d\u00c0-\u024f]+)$" spellcheck="false" size="40">
                   </div>
              </div>
              <br>
              <div class="row topic-create">
                    <label class="col-sm-2 text-right ">Déscription</label>
                  <div class="col-sm-10">
                      <textarea name="content" class="form-control" rows="15" placeholder="Le contenu ..."required
                      aria-required="true" spellcheck="false" pattern="^([- \w\d\u00c0-\u024f]+)$"></textarea>
                  </div>
              </div>
              <br>
                <button id="submit" class="btn btn-primary topic-create center-block">Ajouter</button>
                <?php
                if (isset($erreur)) {
                  echo $erreur;
                }
                ?>
            </form>
        </div>
      
      </div>
    </div>
        <div class="footer"></div>
    </div>
    </body>
    </html>