diff options
Diffstat (limited to 'photospolo/photomodif.php')
-rw-r--r-- | photospolo/photomodif.php | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/photospolo/photomodif.php b/photospolo/photomodif.php new file mode 100644 index 0000000..9be46c0 --- /dev/null +++ b/photospolo/photomodif.php | |||
@@ -0,0 +1,53 @@ | |||
1 | <?php | ||
2 | // PAGE SÉCURISÉE ! impossible de la voir si la variable $_SESSION['mdpvalide'] ne vaut pas 1 | ||
3 | |||
4 | session_start(); | ||
5 | if (isset ($_SESSION["mdpvalide"])) | ||
6 | { | ||
7 | if($_SESSION["mdpvalide"]) // booléen, test si ça vaut 1 | ||
8 | {} // dans ce cas on fait rien et on laisse php lire la suite | ||
9 | else | ||
10 | { | ||
11 | header('Location: ../connexion.php'); | ||
12 | exit (); | ||
13 | // exit() sert à interrompre php qui n'a alors surtout pas besoin d'aller jusqu'en bas de la page | ||
14 | } | ||
15 | } | ||
16 | else | ||
17 | { | ||
18 | header('Location: ../connexion.php'); | ||
19 | exit (); | ||
20 | } | ||
21 | |||
22 | |||
23 | // connexion à la base de données | ||
24 | include("../connexionbase.php"); | ||
25 | |||
26 | |||
27 | // modifier la photo sélectionnée | ||
28 | if (isset ($_GET['id'])) | ||
29 | { | ||
30 | // choix de la ligne en fonction de son id | ||
31 | $requête = $base->prepare('SELECT * FROM photospolo WHERE id = :numero'); | ||
32 | $requête->execute(array('numero' => $_GET['id'])); | ||
33 | |||
34 | while ($données = $requête->fetch()) | ||
35 | { | ||
36 | $nom = $données['nomphoto']; | ||
37 | } | ||
38 | |||
39 | $requête->closeCursor(); | ||
40 | |||
41 | $fichier = fopen('photo.txt','r+'); | ||
42 | ftruncate($fichier,0); // évite les problèmes quand on change pour un titre plus court | ||
43 | fputs($fichier, $nom); | ||
44 | fseek($fichier, 0); | ||
45 | fclose($fichier); | ||
46 | |||
47 | header('Location: ../administration.php?modifphoto=4'); | ||
48 | exit (); | ||
49 | } | ||
50 | else | ||
51 | {} | ||
52 | |||
53 | ?> | ||