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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315
| <?php
// Variable de session
// -------------------
session_start();
if (!isset($_SESSION['login']))
{
header ('Location: index.php');
exit();
}
// session_start(): demarre une nouvelle session ou reprend une session existante
// $_SESSION: variables de session. Tableau associatif des valeurs stockées dans les sessions, et accessible au script courant
// header(): envoie un en-tete HTTP ... on redirige vers la page ... ou type de contenu que contient le message
header('Content-type: text/html; charset=UTF-8');
// FORMULAIRE ACTUALISATION DU TEXTE DE LA PAGE 1
// ----------------------------------------------
// Initialisation des variables
$titre_fp1 ='';
$sous_titre_fp1 ='';
$paragraphe_fp1 ='';
$titre_actualite_fp1 ='';
$paragraphe_actualite_page1 ='';
$theme1_fp1 ='';
$theme2_fp1 ='';
$theme3_fp1 ='';
$theme4_fp1 ='';
$theme5_fp1 ='';
$theme6_fp1 ='';
$theme7_fp1 ='';
$theme8_fp1 ='';
$theme9_fp1 ='';
$theme10_fp1 ='';
$validForm_hidden_fp1 = true;
$validForm_fp1 = true;
$MsgErreur_fp1 = '';
// ---------------------
// TRAITEMENT SI FORMULAIRE SOUMIS
if(isset($_POST['form_page1_submit']))
{
// ---------------------
// RECUPERATION des DONNEES
$titre_fp1 = (isset($_POST['titre_fp1']))? trim($_POST['titre_fp1']) : '';
$sous_titre_fp1 = (isset($_POST['sous_titre_fp1']))? trim($_POST['sous_titre_fp1']) : '';
$paragraphe_fp1 = (isset($_POST['paragraphe_fp1']))? trim($_POST['paragraphe_fp1']) : '';
$titre_actualite_fp1 = (isset($_POST['titre_actualite_fp1']))? trim($_POST['titre_actualite_fp1']) : '';
$paragraphe_actualite_page1 = (isset($_POST['paragraphe_actualite_page1']))? trim($_POST['paragraphe_actualite_page1']) : '';
$theme1_fp1 = (isset($_POST['theme1_fp1']))? trim($_POST['theme1_fp1']) : '';
$theme2_fp1 = (isset($_POST['theme2_fp1']))? trim($_POST['theme2_fp1']) : '';
$theme3_fp1 = (isset($_POST['theme3_fp1']))? trim($_POST['theme3_fp1']) : '';
$theme4_fp1 = (isset($_POST['theme4_fp1']))? trim($_POST['theme4_fp1']) : '';
$theme5_fp1 = (isset($_POST['theme5_fp1']))? trim($_POST['theme5_fp1']) : '';
$theme6_fp1 = (isset($_POST['theme6_fp1']))? trim($_POST['theme6_fp1']) : '';
$theme7_fp1 = (isset($_POST['theme7_fp1']))? trim($_POST['theme7_fp1']) : '';
$theme8_fp1 = (isset($_POST['theme8_fp1']))? trim($_POST['theme8_fp1']) : '';
$theme9_fp1 = (isset($_POST['theme9_fp1']))? trim($_POST['theme9_fp1']) : '';
$theme10_fp1 = (isset($_POST['theme10_fp1']))? trim($_POST['theme10_fp1']) : '';
// ---------------------
// CHAMPS OBLIGATOIRES
$champ_obligatoire_fp1 = array();
$search = array (" ", "-", "'", "ğ", "Ğ", "ş", "Ş", "ı", "I", "Á", "À", "Â", "Ä", "Å", "Ã", "Ç", "É", "È", "Ê", "Ë", "Í", "Ì", "Î", "Ï", "Ñ", "Ó", "Ò", "Ô", "Ö", "Õ", "Ø", "", "Ú", "Ù", "Û", "Ü", "Ý", "", "", "Ð", "Þ", "á", "à", "â", "ä", "å", "ã", "ç", "é", "è", "ê", "ë", "í", "ì", "î", "ï", "ñ", "ó", "ò", "ô", "ö", "õ", "ø", "", "ú", "ù", "û", "ü", "ý", "ÿ", "", "&", "ð", "þ", "ß", "æ", "", "Æ", "");
$replace = array ("", "", "", "t", "t", "t", "t", "t", "t", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a");
if ($titre_fp1=='' || ctype_alnum(str_replace($search, $replace, $titre_fp1))!=true || strlen($titre_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Titre de la page'; }
if ($sous_titre_fp1=='' || ctype_alnum(str_replace($search, $replace, $sous_titre_fp1))!=true || strlen($sous_titre_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Sous titre'; }
if ($paragraphe_fp1=='' || ctype_alnum(str_replace($search, $replace, $paragraphe_fp1))!=true || strlen($paragraphe_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Texte paragraphe'; }
if ($titre_actualite_fp1=='' || ctype_alnum(str_replace($search, $replace, $titre_actualite_fp1))!=true || strlen($titre_actualite_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Titre actualité'; }
if ($paragraphe_actualite_page1=='' || ctype_alnum(str_replace($search, $replace, $paragraphe_actualite_page1))!=true || strlen($paragraphe_actualite_page1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Paragraphe actualité'; }
if ($theme1_fp1=='' || ctype_alnum(str_replace($search, $replace, $theme1_fp1))!=true || strlen($theme1_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Thème 1 actualité'; }
if ($theme2_fp1=='' || ctype_alnum(str_replace($search, $replace, $theme2_fp1))!=true || strlen($theme2_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Thème 2 actualité'; }
if ($theme3_fp1=='' || ctype_alnum(str_replace($search, $replace, $theme3_fp1))!=true || strlen($theme3_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Thème 3 actualité'; }
if ($theme4_fp1=='' || ctype_alnum(str_replace($search, $replace, $theme4_fp1))!=true || strlen($theme4_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Thème 4 actualité'; }
if ($theme5_fp1=='' || ctype_alnum(str_replace($search, $replace, $theme5_fp1))!=true || strlen($theme5_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Thème 5 actualité'; }
if ($theme6_fp1=='' || ctype_alnum(str_replace($search, $replace, $theme6_fp1))!=true || strlen($theme6_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Thème 6 actualité'; }
if ($theme7_fp1=='' || ctype_alnum(str_replace($search, $replace, $theme7_fp1))!=true || strlen($theme7_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Thème 7 actualité'; }
if ($theme8_fp1=='' || ctype_alnum(str_replace($search, $replace, $theme8_fp1))!=true || strlen($theme8_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Thème 8 actualité'; }
if ($theme9_fp1=='' || ctype_alnum(str_replace($search, $replace, $theme9_fp1))!=true || strlen($theme9_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Thème 9 actualité'; }
if ($theme10_fp1=='' || ctype_alnum(str_replace($search, $replace, $theme10_fp1))!=true || strlen($theme10_fp1)<2) {$validForm_fp1 = false; $champ_obligatoire_fp1[] = 'Thème 10 actualité'; }
if(count($champ_obligatoire_fp1)>0)
{
$MsgErreur_fp1 .= '*Champs obligatoires : '.implode(', ',$champ_obligatoire_fp1).'<br />';
echo "<script type='text/javascript'>alert(\"Veuillez renseigner tous les champs obligatoires!\")</script>";
// "\\n" pour aller a la ligne: "\n" n'est pas pris en compte dans la chaine de caractères car l'antislash en php permet d'afficher des caractères spéciaux dans une chaîne de caractères
}
// -----------------------
// OK SI PAS D'ERREUR
if($validForm_fp1 === true)
{
// ---------------------
if
(
$titre_fp1!='' && $sous_titre_fp1!='' && $paragraphe_fp1!='' && $titre_actualite_fp1!='' && $paragraphe_actualite_page1!='' && $theme1_fp1!='' &&
$theme2_fp1!='' && $theme3_fp1!='' && $theme4_fp1!='' && $theme5_fp1!='' && $theme6_fp1!='' && $theme7_fp1!='' && $theme8_fp1!='' && $theme9_fp1!='' && $theme10_fp1!=''
)
{
// ECRITURE dans la table
include_once('./connexion-a2bis.php');
//Preparer la requete
$sql = 'UPDATE ad_page1 SET
h1=:h1,
h2=:h2,
texte=:texte,
actualite_titre=:actualite_titre,
actualite_texte=:actualite_texte,
actualite_li1=:actualite_li1,
actualite_li2=:actualite_li2,
actualite_li3=:actualite_li3,
actualite_li4=:actualite_li4,
actualite_li5=:actualite_li5,
actualite_li6=:actualite_li6,
actualite_li7=:actualite_li7,
actualite_li8=:actualite_li8,
actualite_li9=:actualite_li9,
actualite_li10=:actualite_li10
WHERE id_page1=:id_page1';
$requete2 = $connexion_bdd ->prepare($sql);
//Associer des valeurs aux place holders
$requete2->bindValue(':h1', $h1);
$requete2->bindValue(':h2', $h2);
$requete2->bindValue(':texte', $texte);
$requete2->bindValue(':actualite_titre', $actualite_titre);
$requete2->bindValue(':actualite_texte', $actualite_texte);
$requete2->bindValue(':actualite_li1', $actualite_li1);
$requete2->bindValue(':actualite_li2', $actualite_li2);
$requete2->bindValue(':actualite_li3', $actualite_li3);
$requete2->bindValue(':actualite_li4', $actualite_li4);
$requete2->bindValue(':actualite_li5', $actualite_li5);
$requete2->bindValue(':actualite_li6', $actualite_li6);
$requete2->bindValue(':actualite_li7', $actualite_li7);
$requete2->bindValue(':actualite_li8', $actualite_li8);
$requete2->bindValue(':actualite_li9', $actualite_li9);
$requete2->bindValue(':actualite_li10', $actualite_li10);
//Compiler et executer la requete
$requete2->execute();
//Clore la requete preparee
$requete2 -> closeCursor();
$requete2 = NULL;
}
echo "<script type='text/javascript'>alert(\"Votre projet nous est parvenu.\\nNous vous contactons dans les meilleurs délais pour satisfaire vos attentes.\")</script>";
// ---------------------
// On vide
$titre_fp1 ='';
$sous_titre_fp1 ='';
$paragraphe_fp1 ='';
$titre_actualite_fp1 ='';
$paragraphe_actualite_page1 ='';
$theme1_fp1 ='';
$theme2_fp1 ='';
$theme3_fp1 ='';
$theme4_fp1 ='';
$theme5_fp1 ='';
$theme6_fp1 ='';
$theme7_fp1 ='';
$theme8_fp1 ='';
$theme9_fp1 ='';
$theme10_fp1 ='';
}
}
?>
<?php
// ---------------------
// REPERAGE PAGE EN COURS
// ---------------------
$page_en_cours=basename(__FILE__);
// ---------------------
// IP du visiteur
$ipvisiteur = $_SERVER["REMOTE_ADDR"];
// ---------------------
// Format d'affichage de la date (au choix)
$date = getdate(); // On récupère la date d'aujourd'hui.
// ---------------------
?>
<!DOCTYPE html> <!--on declare au validator le langage utilisé: html5-->
<html lang="fr">
<?php include("0-head.php"); ?>
<body>
<div class="container">
<?php include("0-entete.php"); ?>
<?php include("0-menu.php"); ?>
<br>
<hr>
<hr>
<div class="row">
<div class="col-lg-6 col-md-12 col-sm-12 col-xs-12">
<h1>Modifier la page d'acceuil</h1>
Bienvenue <?php echo htmlentities(trim($_SESSION['login'])); ?> <br />
<a href="15-admin-deconnexion.php" target="_self" title="Déconnexion">Déconnexion</a>
<br />
<a href="15-admin-membre.php" target="_self" title="Inscription">Retour à l'Acceuil, Administration du site</a>
</div>
</div>
<br /><br /><br />
<div class="row">
<div class="col-lg-8">
<?php
include_once('./connexion-a2bis.php');
//Preparer la requete
$sql = 'SELECT * FROM ad_page1 WHERE id_page1=?';
$requete2 = $connexion_bdd ->prepare($sql);
//Associer des valeurs aux place holders
$requete2->bindValue(1, '1', PDO::PARAM_STR);
//Compiler et executer la requete
$requete2->execute();
//Recuperer toutes les donnees retournees
foreach($requete2->fetchAll() as $donnee)
{
?>
<form method="post" action="16-modifier-page1.php">
<fieldset class="form-group">
<label for="id_a">Titre de la page (max 100 caractères)</label>
<input type="text" name="titre_page1" class="form-control" id="id_a" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['h1']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_b">Sous titre (max 100 caractères)</label>
<input type="text" name="sous_titre_page1" class="form-control" id="id_b" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['h2']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_c">Texte paragraphe (max 700 caractères)</label>
<textarea name="paragraphe_page1" class="form-control" id="id_c" rows="3" placeholder="" maxlength="700"><?php echo htmlspecialchars($donnee['texte']); ?></textarea>
</fieldset>
<hr>
<fieldset class="form-group">
<label for="id_d">Titre actualité (max 100 caractères)</label>
<input type="text" name="titre_actualite" class="form-control" id="id_d" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_titre']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_e">Paragraphe actualité (max 200 caractères)</label>
<textarea name="paragraphe_actualite_page1" class="form-control" id="id_e" rows="3" placeholder="" maxlength="200"><?php echo htmlspecialchars($donnee['actualite_texte']); ?></textarea>
</fieldset>
<fieldset class="form-group">
<label for="id_f">Thème1 actualité (max 100 caractères)</label>
<input type="text" name="theme1" class="form-control" id="id_f" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_li1']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_g">Thème2 actualité (max 100 caractères)</label>
<input type="text" name="theme2" class="form-control" id="id_g" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_li2']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_h">Thème3 actualité (max 100 caractères)</label>
<input type="text" name="theme3" class="form-control" id="id_h" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_li3']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_i">Thème4 actualité (max 100 caractères)</label>
<input type="text" name="theme4" class="form-control" id="id_i" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_li4']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_j">Thème5 actualité (max 100 caractères)</label>
<input type="text" name="theme5" class="form-control" id="id_j" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_li5']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_k">Thème6 actualité (max 100 caractères)</label>
<input type="text" name="theme6" class="form-control" id="id_k" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_li6']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_l">Thème7 actualité (max 100 caractères)</label>
<input type="text" name="theme7" class="form-control" id="id_l" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_li7']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_m">Thème8 actualité (max 100 caractères)</label>
<input type="text" name="theme8" class="form-control" id="id_m" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_li8']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_n">Thème9 actualité (max 100 caractères)</label>
<input type="text" name="theme9" class="form-control" id="id_n" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_li9']); ?>">
</fieldset>
<fieldset class="form-group">
<label for="id_o">Thème10 actualité (max 100 caractères)</label>
<input type="text" name="theme10" class="form-control" id="id_o" placeholder="" maxlength="100" value="<?php echo htmlspecialchars($donnee['actualite_li10']); ?>">
</fieldset>
<div class="row">
<div class="col-lg-12 col-md-6 col-sm-8 col-xs-12">
<button type="submit" name="form_page1_submit" class="btn btn-primary">Envoyer</button>
<?php if(!empty($MsgErreur_fp1)) { echo ('<p class="message_erreur_red">'); echo $MsgErreur_fp1; echo ('</p>'); } ?>
</div>
</div>
</form>
<?php
}
//Clore la requete preparee
$requete2 -> closeCursor();
$requete2 = NULL;
?>
</div>
</div>
</div>
</body>
</html> |
Partager