salut a tous moi c'est Tissebaos,
Je suis sur un tp académique 'PHP SGBD' ça fait un moment que j'essai de faire un 'INSERT' et depuis ça me donne l'erreur suivante
quand je regarde le code je vois pas l'erreur a la ligne 56 quelqu'un peut il m'aider? merci !!!Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\xampp\htdocs\docweb\projet_election\function\inscription.class.php:56 Stack trace: #0 C:\xampp\htdocs\docweb\projet_election\function\inscription.class.php(56): PDOStatement->execute(Array) #1 C:\xampp\htdocs\docweb\projet_election\inscription.php(21): inscription->enregistrement() #2 {main} thrown in C:\xampp\htdocs\docweb\projet_election\function\inscription.class.php on line 56
voici le code source
*page d'inscription
*la classe contenant les fonctions...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php session_start(); include_once "function/function.php"; include_once "function/inscription.class.php"; $bdd = bdd(); if (isset($_POST["ssn"]) AND isset($_POST["nom"]) AND isset($_POST["prenom"]) AND isset($_POST["dateN"]) AND isset($_POST["adresse"]) AND isset($_POST["login"]) AND isset($_POST["password"]) AND isset($_POST["caste"]) AND isset($_POST["entite"]) ) { $inscription = new inscription($_POST['ssn'],$_POST['nom'],$_POST['prenom'],$_POST['dateN'],$_POST['adresse'],$_POST['login'],$_POST['password'],$_POST['caste'],$_POST['entite']); $verif = $inscription->verif(); if ($verif == "OK") {/* tout est bon*/ if($inscription->enregistrement()) { if($inscription->session()) { /* tout est mis en session */ header("Location: personel.php"); } } else {/* Erreur lors de l'enregistrement */ echo "une erreur est survenue"; } } else { $erreur = $verif; } } require 'header_inc.php'; ?> <!--inscription électeur--> <div id="inscriptionElecteur" class="w3-modal" style="display: block;"> <div class="w3-modal-content w3-round-xlarge w3-card-4 w3-animate-zoom" style="max-width:400px"> <div class="w3-center"><br> <span class="w3-text-blue-gray w3-xxlarge">inscriptionElecteur</span> </div> <form class="w3-container" method="post" action="inscription.php"> <div class="w3-section"> <input class="w3-input w3-round w3-border w3-small w3-margin-bottom" placeholder="SSN..." name="ssn" type="number"> <input class="w3-input w3-round w3-border w3-small w3-margin-bottom" placeholder="Nom..." name="nom" type="text"> <input class="w3-input w3-round w3-border w3-small w3-margin-bottom" placeholder="Prénom..." name="prenom" type="text"> <input class="w3-input w3-round w3-border w3-small w3-margin-bottom" placeholder="Date de naissance..." name="dateN" type="date"> <input class="w3-input w3-round w3-border w3-small w3-margin-bottom" placeholder="Adresse..." name="adresse" type="text"> <input class="w3-input w3-round w3-border w3-small w3-margin-bottom" placeholder="Login..." name="login" type="text"> <input class="w3-input w3-round w3-border w3-small w3-margin-bottom" placeholder="Password..." name="password" type="password"> <input class="w3-input w3-round w3-border w3-small w3-margin-bottom" placeholder="Caste..." name="caste" type="number"> <input class="w3-input w3-round w3-border w3-small" placeholder="Entité électorale..." name="entite" type="text"> <button class="w3-button w3-round w3-block w3-green w3-section w3-hover-light-green w3-padding" type="submit">S'inscrire <em> (électeur)</em></button> </div> </form> <div class="w3-container w3-border-top w3-round-large w3-padding-16 w3-blue-gray"> <a href="index.php" type="button" class="w3-button w3-red">Cancel</a> <a href="connexion.php" type="button" class="w3-button w3-teal w3-right">Connexion</a> <button onclick="document.getElementById('inscriptionElecteur').style.display='none'; document.getElementById('inscriptionCandidat').style.display='block'" type="button" class="w3-bar w3-btn w3-hover-gray w3-padding w3-round w3-margin-top w3-light-gray">Inscription candidat</button> </div> </div> </div> </body> </html>
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <?php include_once "function.php"; class inscription { private $ssn; private $nom; private $prenom; private $dateN; private $adresse; private $login; private $password; private $caste; private $entite; public function __construct($ssn,$nom,$prenom,$dateN,$adresse,$login,$password,$caste,$entite) { $ssn = htmlspecialchars($ssn); $nom = htmlspecialchars($nom); $prenom = htmlspecialchars($prenom); $dateN = htmlspecialchars($dateN); $adresse = htmlspecialchars($adresse); $login = htmlspecialchars($login); $password = htmlspecialchars($password); $caste = htmlspecialchars($caste); $entite = htmlspecialchars($entite); $this->ssn = $ssn; $this->nom = $nom; $this->prenom = $prenom; $this->dateN = $dateN; $this->adresse = $adresse; $this->login = $login; $this->password = $password; $this->caste = $caste; $this->entite = $entite; $this->bdd = bdd(); } public function verif() { if(strlen($this->password) > 5 AND strlen($this->password) < 20) {/* mot de passe bon */ return "OK"; } else { $erreur = "Le mot de passe doit contenir entre 5 et 20 caractères"; return $erreur; } } public function enregistrement() { $requete = $this->bdd->prepare("INSERT INTO electeur(ssn,nomPersonne,prenomPersonne,dateNaissancePersonne,adressePersonne,loginElecteur,passwordElecteur,castePersonne,nomEntiteElectorale) VALUES(:ssn,:nom,:prenom,:dateN,:adresse,:login,:password,:caste,:entite)"); $requete->execute(array('ssn'=>$this->ssn, 'nomPersonne'=>$this->nom, 'prenomPersonne'=>$this->prenom, 'dateNaissancePersonne'=>$this->dateN, 'adressePersonne'=>$this->adresse, 'loginElecteur'=>$this->login, 'passwordElecteur'=>$this->password, 'castePersonne'=>$this->caste, 'nomEntiteElectorale'=>$this->entite)); return 1; } public function session() { $requete = $this->bdd->prepare("SELECT nomPersonne, prenomPersonne, adressePersonne FROM electeur WHERE loginElecteur = :login"); $requete->execute(array("login"=> $this->login)); $requete = $requete->fetch(); $_SESSION["nomPersonne"] = $requete["nomPersonne"]; $_SESSION["prenomPersonne"] = $requete["prenomPersonne"]; $_SESSION["adressePersonne"] = $requete["adressePersonne"]; $_SESSION["login"] = $this->login; return 1; } } ?>
Partager