Create home page
This commit is contained in:
parent
72cf463993
commit
cf61f9dc6f
6 changed files with 38 additions and 5 deletions
|
@ -12,7 +12,7 @@ const BD_PWD = '';
|
|||
const LANG ='FR-fr';
|
||||
|
||||
// Paramètres du site : nom de l'auteur ou des auteurs
|
||||
const AUTEUR = '';
|
||||
const AUTEUR = 'Florian Charlaix';
|
||||
|
||||
//dossiers racines du site
|
||||
define('PATH_CONTROLLERS','./controllers/c_');
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once(PATH_MODELS.$page.'.php');
|
||||
|
||||
//appel de la vue
|
||||
require_once(PATH_VIEWS.$page.'.php');
|
||||
|
|
|
@ -7,6 +7,6 @@ define('MENU_ACCUEIL','Accueil');
|
|||
define('TEXTE_PAGE_404','Oops, la page demandée n\'existe pas !');
|
||||
define('MESSAGE_ERREUR',"Une erreur s'est produite");
|
||||
|
||||
define('TITRE', 'TITRE provisoire');
|
||||
define('TITRE', 'Le site des sondages');
|
||||
define('POLLS_LIST', 'Liste des sondages');
|
||||
define('ERREUR_QUERY', 'Problème d\'accès à la base de données. Contactez l\'administrateur');
|
||||
|
||||
|
|
12
lib/getPDD.php
Normal file
12
lib/getPDD.php
Normal file
|
@ -0,0 +1,12 @@
|
|||
<?php
|
||||
|
||||
function getPDO() {
|
||||
try {
|
||||
$bdd = new PDO("mysql:host=" . BD_HOST . ";dbname=" . BD_DBNAME . ";charset = utf8", BD_USER, BD_PWD);
|
||||
$bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$bdd->exec("set names utf8");
|
||||
return $bdd;
|
||||
} catch (Exception $e) {
|
||||
return $e;
|
||||
}
|
||||
}
|
13
models/m_accueil.php
Normal file
13
models/m_accueil.php
Normal file
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
require_once("lib/getPDD.php");
|
||||
|
||||
$bdd = getPDO();
|
||||
|
||||
if ($bdd instanceof PDO) {
|
||||
$req = $bdd->prepare("SELECT * FROM Sondage");
|
||||
$req->execute();
|
||||
$polls = $req->fetchAll();
|
||||
$req->closeCursor();
|
||||
} elseif ($bdd instanceof Exception)
|
||||
$alert = choixAlert("query");
|
|
@ -7,8 +7,14 @@
|
|||
<?php require_once(PATH_VIEWS.'alert.php');?>
|
||||
|
||||
<!-- Début de la page -->
|
||||
|
||||
|
||||
<h2><?= POLLS_LIST ?></h2>
|
||||
<?php if (isset($polls) and $polls) { ?>
|
||||
<ul>
|
||||
<?php foreach ($polls as $poll) { ?>
|
||||
<li><a href="index.php?page=poll&id=<?= $poll['sonId'] ?>"><?= $poll["question"] ?></a></li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
<?php } ?>
|
||||
<!-- Fin de la page -->
|
||||
|
||||
<!-- Pied de page -->
|
||||
|
|
Reference in a new issue