Commit 011cb4541623b2a5f76924ac0d707985bfda1812
1 parent
51e32633
Ajout compte
Showing
5 changed files
with
67 additions
and
13 deletions
Show diff stats
site/accesBase.php
... | ... | @@ -45,12 +45,12 @@ |
45 | 45 | return pg_affected_rows($result); |
46 | 46 | } |
47 | 47 | |
48 | - function inscription($id, $pwd, $nom, $prenom) | |
48 | + function inscription($id, $pwd, $nom, $prenom, $groupe) | |
49 | 49 | { |
50 | 50 | $db = connexion(); |
51 | 51 | $num = countMember() +1; |
52 | 52 | $pwd_hache = password_hash($pwd, PASSWORD_DEFAULT); |
53 | - $query = "INSERT INTO membres VALUES('$num', '$nom', '$prenom', '$pwd_hache', '$id')"; | |
53 | + $query = "INSERT INTO membres VALUES('$num', '$nom', '$prenom', '$pwd_hache', '$id', '$groupe')"; | |
54 | 54 | $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); |
55 | 55 | if (pg_affected_rows($result)!=0){ |
56 | 56 | return True; |
... | ... | @@ -59,6 +59,26 @@ |
59 | 59 | return False; |
60 | 60 | } |
61 | 61 | } |
62 | + | |
63 | + function getGroupe($id) | |
64 | + { | |
65 | + $db = connexion(); | |
66 | + $query = "SELECT groupe FROM membres identifiant = '$id'"; | |
67 | + $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); | |
68 | + $tab = pg_fetch_assoc($result); | |
69 | + deconnexion($db); | |
70 | + return $tab['groupe']; | |
71 | + } | |
72 | + | |
73 | + functin getGroupes() | |
74 | + { | |
75 | + $db = connexion(); | |
76 | + $query = "SELECT * FROM groupes"; | |
77 | + $result = pg_query($db, $query) or die("La requête a echoué : ".pg_last_error()); | |
78 | + $tab = pg_fetch_all($result); | |
79 | + deconnexion($db); | |
80 | + return $tab; | |
81 | + } | |
62 | 82 | |
63 | 83 | function getMembreByIdPwd($id, $pwd) |
64 | 84 | { |
... | ... | @@ -79,7 +99,7 @@ |
79 | 99 | return $tab; |
80 | 100 | } |
81 | 101 | |
82 | - function upload($index,$maxsize=FALSE,$extensions=FALSE) | |
102 | + /*function upload($index,$maxsize=FALSE,$extensions=FALSE) | |
83 | 103 | { |
84 | 104 | //Test1: fichier correctement uploadé |
85 | 105 | if (!isset($_FILES[$index]) OR $_FILES[$index]['error'] > 0) return FALSE; |
... | ... | @@ -94,7 +114,7 @@ |
94 | 114 | $fichier = $name.".".$extension_upload; |
95 | 115 | //$fichier = basename($_FILES[$index]['name']); |
96 | 116 | return move_uploaded_file($_FILES['fichier']['tmp_name'],$dossier.$fichier); |
97 | - } | |
117 | + }*/ | |
98 | 118 | |
99 | 119 | function load($tmp_name, $name) |
100 | 120 | { | ... | ... |
site/formInscription.php
1 | +<?php | |
2 | +if(getGroupe($_SESSION['Login'])!=0) | |
3 | +{ header("Location: accueil.php"); } | |
4 | + | |
5 | +$groupes = getGroupes(); | |
6 | +?> | |
1 | 7 | <div class="row"> |
2 | 8 | <div class="col-4 col-md-4 offset-md-4 offset-4"> |
3 | 9 | <br/> |
... | ... | @@ -16,6 +22,21 @@ |
16 | 22 | </tr> |
17 | 23 | |
18 | 24 | <tr> |
25 | + <td>Groupe : </td> | |
26 | + <td> | |
27 | + <select id="groupe" name="groupe" required /> | |
28 | + <option> </option> | |
29 | + <?php | |
30 | + foreach($groupes as $groupe) | |
31 | + { | |
32 | + echo "<option value=$groupe['id']>$groupe['nom']</option>" | |
33 | + } | |
34 | + ?> | |
35 | + </select> | |
36 | + </td> | |
37 | + </tr> | |
38 | + | |
39 | + <tr> | |
19 | 40 | <td>Identifiant : </td> |
20 | 41 | <td><input type="text" name="id" placeholder="Entrez votre identifiant" maxlength="30" required="true" /></td> |
21 | 42 | </tr> | ... | ... |
site/header.php
... | ... | @@ -12,10 +12,16 @@ |
12 | 12 | ?> |
13 | 13 | <a href="ajoutRaspberry.php"><i class="far fa-plus-square"></i> Raspberry</a> |
14 | 14 | <a href="ajoutCapteur.php"><i class="far fa-plus-square"></i> Capteur</a> |
15 | - <a href="send.php"><i class="fa fa-file-upload"></i> Envoyer un code</a> | |
15 | + <a href="send.php"><i class="fa fa-file-upload"></i> Upload</a> | |
16 | 16 | <a href="history.php"><i class="fas fa-history"></i> Historique</a> |
17 | 17 | <a href="rechercheGraphe.php"><i class="fas fa-chart-line"></i> Graphiques</a> |
18 | 18 | <a href="data.php"><i class="fas fa-database"></i> Valeurs</a> |
19 | + <?php | |
20 | + if(getGroupe($_SESSION['Login'])==0) | |
21 | + { | |
22 | + ?><a href="inscrire.php"><i class="far fa-plus-square"></i> Compte</a><?php | |
23 | + } | |
24 | + ?> | |
19 | 25 | <a href="deconnecter.php"><i class="fa fa-power-off"></i> Deconnexion</a> |
20 | 26 | <?php |
21 | 27 | } | ... | ... |
site/inscription.php
1 | 1 | <?php |
2 | 2 | session_start(); |
3 | 3 | require("accesBase.php") ; |
4 | +if(getGroupe($_SESSION['Login'])!=0) | |
5 | +{ header("Location: accueil.php"); } | |
4 | 6 | ?> |
5 | 7 | |
6 | 8 | <!DOCTYPE html> |
... | ... | @@ -23,23 +25,23 @@ require("accesBase.php") ; |
23 | 25 | <div class="row syst"> |
24 | 26 | <div class="inscritpion"> |
25 | 27 | <?php |
28 | + $retour = "Nouveau compte créé avec succès "; | |
26 | 29 | if (notAMember($_POST["id"])){ |
27 | 30 | if($_POST["pass1"]==$_POST["pass2"]){ |
28 | - if(inscription($_POST["id"], $_POST["pass1"], $_POST["nom"], $_POST["prenom"])) | |
31 | + if(inscription($_POST["id"], $_POST["pass1"], $_POST["nom"], $_POST["prenom"], $_POST["groupe"])) | |
29 | 32 | { |
30 | 33 | $_SESSION['Login'] = $_POST['id']; |
31 | 34 | $_SESSION['Password'] = $_POST['pass1']; |
32 | 35 | ?><meta http-equiv="Refresh" content="0;url=accueil.php" /><?php |
33 | 36 | } |
34 | 37 | else |
35 | - echo "erreur inscri"; | |
36 | - | |
38 | + $retour = "Echec de la création du compte !"; | |
37 | 39 | } |
38 | 40 | else |
39 | - echo "erreur pwd"; | |
41 | + $retour = "Les 2 mots de passe ne sont pas identiques !"; | |
40 | 42 | } |
41 | 43 | else{ |
42 | - echo "erreur membre"; | |
44 | + $retour = "Le compte existe déjà !"; | |
43 | 45 | } |
44 | 46 | ?> |
45 | 47 | </div> | ... | ... |
site/inscrire.php
... | ... | @@ -7,7 +7,12 @@ |
7 | 7 | |
8 | 8 | <!-- Contenu du site --> |
9 | 9 | <body> |
10 | - <?php include("header.php"); ?> | |
11 | - <?php include("formInscription.php");?> | |
10 | + <?php | |
11 | + include("header.php"); | |
12 | + if(getGroupe($_SESSION['Login'])==0) | |
13 | + { include("formInscription.php"); } | |
14 | + else | |
15 | + { header("Location: accueil.php"); } | |
16 | + ?> | |
12 | 17 | </body> |
13 | -</html> | |
14 | 18 | \ No newline at end of file |
19 | +</html> | ... | ... |