Notice: Undefined index

Résolu/Fermé
devdeb22 Messages postés 30 Date d'inscription mercredi 18 avril 2018 Statut Membre Dernière intervention 9 février 2020 - 19 avril 2018 à 00:10
devdeb22 Messages postés 30 Date d'inscription mercredi 18 avril 2018 Statut Membre Dernière intervention 9 février 2020 - 19 avril 2018 à 15:54
Bonjour,

Je suis novice en programmation et je souhaite rejoindre le monde merveilleux de la programmation qui est le votre.


Voilà le défis que je rencontre.

Je suis en train de créer un site en local pour apprendre à coder.

Sauf que ça fait 3 jours que j'ai rencontre un problème avec un fichier php et que je n'arrive pas à en venir à bout.


Lorsque je charge la page "web" du fichier php en question voilà ce qu'il m'envoie comme message.


( ! ) Notice: Undefined index: MotDePasse_1 in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 94
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0

( ! ) Notice: Undefined index: Formation in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 96
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0

( ! ) Notice: Undefined index: Prenom in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 96
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0

( ! ) Notice: Undefined index: Nom in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 96
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0

( ! ) Notice: Undefined index: Pseudo in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 96
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0

( ! ) Notice: Undefined index: Sexe in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 96
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0

( ! ) Notice: Undefined index: DateDeNaissance in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 96
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0

( ! ) Notice: Undefined index: AdresseMail_1 in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 96
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0

( ! ) Notice: Undefined variable: MotDePasse_1 in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 96
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0

( ! ) Notice: Undefined index: Promo in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 96
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0

( ! ) Warning: PDOStatement::execute() expects at most 1 parameter, 9 given in C:\wamp\www\Offre\HTML\InscriptionOffre.php on line 96
Call Stack
# Time Memory Function Location
1 0.0011 145432 {main}( ) ...\InscriptionOffre.php:0
2 0.1356 154904 execute ( ) ...\InscriptionOffre.php:96
Votre compte à était créé avec succès !






Et voici le code :


<?php
if(!empty($_POST)){

$errors=array();


if(empty($_POST['Prenom'])){

$errors['Prenom']="Vous n'avez pas saisi votre prénom";

}


if(empty($_POST['Nom'])){

$errors['Nom']="Vous n'avez pas saisi votre nom";

}


if(empty($_POST['Pseudo']) or !preg_match('/^[a-zA-Z0-9_]+$/', $_POST['Pseudo'])){

$errors['Pseudo']="Vous n'avez pas saisi votre pseudo";

}


if(empty($_POST['DateDeNaissance'])){

$errors['DateDeNaissance']="Vous n'avez pas saisi votre date de naissance";

}


if(empty($_POST['AdresseMail_1'])){

$errors['AdresseMail_1']="Vous n'avez pas saisi votre adresse mail";

}


if(empty($_POST['AdresseMail_2']) or !filter_var($_POST['AdresseMail_2'],FILTER_VALIDATE_EMAIL)){

$errors['AdresseMail_2']="Vous n'avez pas confirmer votre adresse mail";

}


if(empty($_POST['MotDePasse_1']) or $_POST['MotDePasse_1'] != $_POST['MotDePasse_2'])
{

$errors['MotDePasse_1']="Vous n'avez pas saisi votre mot de passe";

}


if($_POST['MotDePasse_1'] !== $_POST['MotDePasse_2'])
{

$errors['ConfirmationMp']="Vos 2 mots de passe ne sont pas identique";

}


if(empty($_POST['MotDePasse_2'])){

$errors['MotDePasse_2']="Vous n'avez pas confirmé votre mot de passe";

}


if(empty($_POST['Promo'])){

$errors['Promo']="Vous n'avez pas saisie votre mot code Promo";

}

var_dump($errors);

}


if (empty($errors)){


require_once '../db.php';

$req = $pdo -> prepare("INSERT INTO inscrits SET Formation = ?, Prenom = ?, Nom = ?, Pseudo = ?, Sexe = ?, DateDeNaissance = ?, AdresseMail_1 = ?, MotDePasse_1 = ?, Promo = ?");

$password = password_hash($_POST['MotDePasse_1'], PASSWORD_BCRYPT);

$req->execute([$_POST['Formation']], [$_POST['Prenom']], [$_POST['Nom']], [$_POST['Pseudo']], [$_POST['Sexe']],[$_POST['DateDeNaissance']], [$_POST['AdresseMail_1']], $MotDePasse_1,[$_POST['Promo']]);

die("Votre compte à était créé avec succès !");



}

?>


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Page d'inscription</title>
</head>
<body>


<p>Inscrivez-vous</p>
<form action="" method="POST">
<table>
<tr>
<td >
A quelle formation vous inscrivez-vous ?
</td>
<td >
<select name="Formation">
<option value="mathematiques">Mathématiques</option>
<option value="conception_mecanique">Conception de systèmes mécaniques</option>
</select>
</td>
</tr>


<tr>
<td>
<label for="Prenom">Prénom :</label>
</td>
<td>
<input type="text" name="Prenom" id="Prenom" placeholder="Prénom">
</td>
</tr>
<tr>
<td>
<label for="Nom">Nom :</label>
</td>
<td>
<input type="text" name="Nom" id="Nom" placeholder="Nom">
</td>
</tr>
<tr>
<td>
<label for="Pseudo">Pseudo :</label>
</td>
<td>
<input type="text" name="Pseudo" id="Pseudo" placeholder="Pseudo">
</td>
</tr>
<tr>
<td>
<label for="Sexe">Sexe :</label>
</td>
<td>
Femme<input type="radio" name="Sexe" value="Femme">
Homme<input type="radio" name="Sexe" value="Homme">
</td>
</tr>
<tr>
<td>
<label for="DateDeNaissance">Date de naissance :</label>
</td>
<td>
<input type="date" name="DateDeNaissance" id="DateDeNaissance">
</td>
</tr>
<tr>
<td>
<label for="AdresseMail_1">Adresse mail :</label>
</td>
<td>
<input type="email" name="AdresseMail_1" id="email" placeholder="contact@contact.com">
</td>
</tr>
<tr>
<td>
<label for="AdresseMail_2">Confirmer votre adresse mail :</label>
</td>
<td >
<input type="email" name="AdresseMail_2" id="AdresseMail_2" placeholder="contact@contact.com">
</td>
</tr>
<tr>
<td>
<label for="MotDePasse_1">Choisisez votre code secret :</label>
</td>
<td>
<input type="password" name="MotDePasse_1" id="MotDePasse_1" placeholder="Votre de code secret">
</td>
</tr>
<tr>
<td>
<label for="MotDePasse_1">Confirmer votre code secret :</label>
</td>
<td >
<input type="password" name="MotDePasse_2" id="MotDePasse_2" placeholder="Votre de code secret">
</td>
</tr>
<tr>
<td>
<label for="Connu">Souhaitez-vous tester votre niveau de ShiKomori ? :</label>
</td>
<td >
<input type="text" name="origines" id="origines" placeholder="pseudo">
</td>
</tr>
<tr>
<td>

</td>
<td >

</td>
</tr>
<tr>
<td>
<input type="submit" value="Cliquez ici pour nous demander le code Promo" name="DemandeCodePromo"/>
</td>
</tr>
<tr>
<td>
<label for="Promo">Entrez votre code promotionel :</label>
</td>
<td>
<input type="number" name="Promo" id="Promo" placeholder="Votre promo">
</td>
</tr>
</table>
<input type="submit" value="M'inscrire" name="ValiderInscription"/>
</form>
</body>
</html>




Alors si quelqu'un aurai la gentillesse de m'offrir une réponse ou même un bout de réponse pour que je puisse réfléchir dessus ça serait bien.

Car je ne vois pas comment les variables ne sont pas défini, je rappelle juste que je suis novice ne programmation. merci

2 réponses

jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 4 649
19 avril 2018 à 00:28
0
jordane45 Messages postés 38138 Date d'inscription mercredi 22 octobre 2003 Statut Modérateur Dernière intervention 17 avril 2024 4 649
19 avril 2018 à 00:31
Et pour corriger ton souci... Ta variable c'est $password et non $MotDePass_1
0