Bonjour !
J'ai un tableau :
Poste Date Type Mail Dossier Actions
balbala 25/02/1425 mail@mail cv_5.pdf + | -
Je peux supprimer ou modifier les données de ce tableau qui sont sur ma BDD mais ça ne fonctionne pas.
( ! ) Notice: Undefined index
( ! ) Notice: Undefined offset
Voici mon code de formulaire :
Le traitement du formulaire ci-dessus :
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 //formulaire de modification d'un élément $req="select * from adherent where numCV=".$_GET['id'] ; $exec=mysql_query($req); $tab=explode("-",$dt); $dt=$ligne['dateCV']; $tab=explode("-",$dt); $dateCV=$tab[2]."/".$tab[1]."/".$tab[0]; echo '<form method="POST" action="#" name="saisieCV" onSubmit="return CV()">'; echo '<div class="formAddSuppEdit" id="ancre_modif"><h3><br>Mise à jour d\'une offre</h3>'; if (isset($_SESSION['mess']) && ($_SESSION['mess']!="")) { echo '<p class="erreur">'.$_SESSION['mess'].'</p>' ; } echo 'Modifier type de poste : <input type ="text" name="typeCV" id="typeCV" size=60 value="'.$ligne['typeCV'].'"/> <br>' ; echo '<input type="hidden" name="id" id="id" value="'.$ligne['numCV'].'"/>' ; echo 'Poste: <input type="text" name="posteCV" id="posteCV" size=80 value="'.$ligne['posteCV'].'"/><br>' ; echo '<input type="submit" class="btn_addSuppEdit" value="Valider" />' ; echo '<input type="reset" class="btn_addSuppEdit" value="Effacer" />' ; echo '</form></div>' ; } // suppression d'un élément if ($_GET['action']=="S") { //formulaire de suppression d'un élément if (isset($_GET['id'])) { // affichage élément à supprimer et demande de validation $req="select * from adherent where numCV='".$_GET['id']."'" ; $exec=mysql_query($req); $tab=explode("-",$dt); echo '<form method="POST" action="#" name="saisieCV" onSubmit="return CV()">' ; echo '<input type="hidden" name="id" id="id" value="'.$ligne['numCV'].'"/>' ; echo '<div class="formAddSuppEdit" id="ancre_suppr"><h3>Suppression d\'un compte rendu</h3>'; echo 'Êtes-vous certain de vouloir supprimer cette offre ?' ; echo '<br><input type="submit" name="btnOui" class="btn_addSuppEdit" value="Oui" /> <input type="submit" name="btnNon" class="btn_addSuppEdit" value="Non" />' ; echo '</form></div>' ; } else { // l'élément ne peut être supprimé echo '<form>' ; if (isset($_SESSION['mess'])) { echo '<p class="erreur">'.$_SESSION['mess'].'</p>' ; } echo '</form>' ; }
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 /* MODIFICATION */ $_SESSION['mess'] = ''; $_typeCV = htmlentities($_POST["typeCV"]) ; $_dateCV = htmlentities($_POST["dateCV"]); $_posteCV = htmlentities ($_POST["posteCV"]); $_id=$_POST["id"]; if ( !isset($_dateCV) || !isset($_typeCV) || !isset($_posteCV)) { echo' <script> document.location="javascript:history.back()"; </script>'; } else { $dt=$_dateCV; $tab=explode("/",$dt); $dateCV=$tab[2]."-".$tab[1]."-".$tab[0]; //on a changé un champ $sql= "update cvtheque set dateCV='$dateCV', typeCV='$_typeCV', posteCV='$_posteCV' where numCV = $_id"; mysql_query($sql) or die("Un problème de modification a eu lieu"); } /* SUPPRESSION */ $_SESSION['mess'] = ''; $_id=htmlentities($_POST["id"]); if (isset($_POST["btnOui"])) $_reponse="oui"; if (isset($_POST["btnNon"])) $_reponse="non"; if ($_reponse=="oui") { mysql_query("delete * from cvtheque where numCV=$_id") or die ("Erreur de suppression"); }
Je ne trouve pas mes erreurs, apparemment ce sont mes variables typeCV, posteCV ... ?
Merci,
lizeal
Partager