Bonjour à tous,
J'ai un problème sur un $_POST qui me renvoie "Undefined variable".
Voilà une grande partie de mon code :
Quand je veux réutiliser la variable $choixcours, il me met bien "erreur" quand on n'a pas encore cliqué sur un bouton, mais il m'affiche
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 <div class="choixcourstitre">Choisissez le niveau souhaité.</div><!--Menu des niveaux--> <table> <tr> <form method="post"> <input class="choixcours" type="submit" name="choixcours" value="6ème"> <input class="choixcours" type="hidden" name="choixcours" value="6ème"> </form> </tr> <tr> <form method="post"> <input class="choixcours" type="submit" name="choixcours" value="4ème"> <input class="choixcours" type="hidden" name="choixcours" value="4ème"> </form> </tr> <tr> <form method="post"> <input class="choixcours" type="submit" name="choixcours" value="3ème"> <input class="choixcours" type="hidden" name="choixcours" value="3ème"> </form> </tr> <tr> <form method="post"> <input class="choixcours" type="submit" name="choixcours" value="3ème A"> <input class="choixcours" type="hidden" name="choixcours" value="3ème A"> </form> </tr> <tr> <form method="post"> <input class="choixcours" type="submit" name="choixcours" value="PP 3ème"> <input class="choixcours" type="hidden" name="choixcours" value="PP 3ème"> </form> </tr> <tr> <form method="post"> <input class="choixcours" type="submit" name="choixcours" value="Stage 3ème"> <input class="choixcours" type="hidden" name="choixcours" value="Stage 3ème"> </form> </tr> </table> <?php if (isset($_POST['choixcours'])) { $choixcours = $_POST['choixcours']; } else { $choixcours = "erreur"; }(là ou je fais un echo $choixcours pour tester).Notice: Undefined variable: choixcours in ... on line ...
Le problème vient donc de mon $_POST['choixcours'] qui ne prend pas les valeurs des <form> (j'ai essayé avec d'autres nom de valeur, cela n'a rien changé).
Qu'ai-je loupé ?
Merci d'avance
Partager