Bonjour
Je suis un grand débutant en PHP (premier cours la semaine passée)
J'ai un travail a faire seulement je n'y arrive pas.
Je dois récupérer des notes grace a un formulaire puis ensuite les afficher dans un tableau et en faire une moyenne seulement le serveur php m'indique des erreures et de ce fait le script ne marche pas. Tout les $_POST['xxx'] ont une erreur d'index indefini apparament et la variable moyenne n'est pas definie.
j'ai essayé tout ce que j'ai pu mais cela ne marche toujours pas.
Je vous pris de bien vouloir m'aidé afin que je puisse comprendre mes erreurs si il vous plait.
voici mon code :
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 <html> <head> <title>Calculer une moyenne</title> </head> <body> <h1>Calcul de votre moyenne au BAC STG "Gestion des systèmes d'information"</h1> <a href="******">Consulter les matières et les coefficients du BAC STG</a> <form action="moyenne.php" method="post"> <table> <tr> <th>Epreuve</th> <th>Note</th> <th>Coefficient</th> </tr> <tr> <td>Français écrit</td> <td><input type="text" name="NoteFecrit"/></td> <td><input type="text" name="coefFecrit" value="2" /></td> </tr> <tr> <td>Français oral</td> <td><input type="text" name="NoteForal"/></td> <td><input type="text" name="coefForal" value="2" /></td> </tr> <tr> <td>Histoire-Géographie</td> <td><input type="text" name="NoteHG"/></td> <td><input type="text" name="coefHG" value="2" /></td> </tr> </table> <br /><br /> <input type="button" value="Calculer la moyenne"/> <input type="reset" value="Remettre à zéro"/> </form> <? $moyenne=($_POST['NoteFecrit']*$_POST['coefFecrit']+$_POST['NoteForal']*$_POST['coefForal']+$_POST['NoteHG']*$_POST['coefhg'])/($_POST['coefFecrit']+$_POST['coefForal']+$_POST['coefhg']; ?> <table> <tr> <td></td> <th>Français Oral</th> <th>Français Ecrit</th> <th>Histoire Géographie</th> </tr> <tr> <th>Notes</th> <td><?php echo $_POST['NoteFecrit']; ?></td> <td><?php echo $_POST['NoteForal']; ?></td> <td><?php echo $_POST['NoteHG']; ?></td> </tr> <tr> <th>Coefficient</th> <td><?php echo $_POST['coefFecrit']; ?></td> <td><?php echo $_POST['coefForal']; ?></td> <td><?php echo $_POST['coefhg']; ?></td> </tr> </table> <table> <tr> <th>Moyenne</th> <td><?php echo $moyenne; ?><td/> </tr> </table> </body> </html>
Merci par avance.
Partager