Bonjour.
Sur une page ma_fiche_film.php quand je clique sur un lien je récupère l'id de mon enregistrement et j'affiche le détail sur une page film_modif.php.
Sur cette page film_modif.php toutes les données sont affichées dans un formulaire 1. Il y a aussi un autre formulaire 2 qui permet d'actualiser une table acteurs.
Quand je valide le formulaire 2 sur lequel j'ajoute un acteur, je perds toutes les données du formulaire 1.
Comment je peux récupérer les infos du formulaire 1 quand je valide le formulaire 2.
Le début de ma page film_modif où j'ai récupéré l'id du film ($_POST['modifier_mon_film']) et l'enregistrement d'un acteur :Ensuite le formulaire avec les données du film
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 <?php require ('connect.php'); $message = ""; if (!isset($_POST['modifier_mon_film'])){ echo "<p align='center'><font color='red'>Vous n'avez pas sélectionné le film à modifier</font></p>"; } else if (isset($_POST['modifier_mon_film'])){ $choix=$_POST['modifier_mon_film']; $sql = mysql_query('SELECT titres.* FROM titres WHERE titres.id_titre = '.$choix.''); if (mysql_num_rows($sql) > 0) { $res = mysql_fetch_array($sql); $idtitre = $res['id_titre']; $titre = stripslashes(htmlentities(trim($res['titre']))); $sortie = $res['sortie']; .... ici j'enregistre un nouvel acteur //enregistrement acteur if(isset($_POST['plus_nomact'])) $plus_nomact=$_POST['plus_nomact']; else $plus_nomact = ""; if(isset($_POST['plus_prenomact'])) $plus_prenomact=$_POST['plus_prenomact']; else $plus_prenomact = ""; if (!empty($_POST['plus_nomact'])) { if (empty($message)){ $plus_nomact = stripslashes(htmlentities(trim(ucwords($plus_nomact)))); $plus_prenomact = stripslashes(htmlentities(trim(ucwords($plus_prenomact)))); $sql = "INSERT INTO acteurs(id_acteur, nom_act, prenom_act) VALUES('','$plus_nomact','$plus_prenomact')"; // insertion dans la table mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error()); } }Le formulaire où je saisi un nouvel acteur :
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 <div style="margin-left:170px"> <form name="modif" method="post" action="index.php?page=film_modif"> <table border ="0"><tr><td> <table border= "0" style="height:500px; background-color:#0099FF" cellpadding=1 cellspacing=0> <colgroup width='150'></colgroup> <colgroup width='500'></colgroup> <tr> <td colspan=3 align="center"><b>Modifier un film</b></td> </tr> <tr> <td align="right">Titre : </td> <td colsapn="2"><input type="text" name="titref" value="<?php echo $titre; ?>" style="width:467px" /></td> </tr> <tr> ... ici j'affiche les acteurs <tr> <!--- sélection des acteurs--> <td align="right" >Avec : </td> <td> <?php $sql = mysql_query('Select * From titres_acteurs WHERE id_titre = '.$choix.''); $nombreligne = mysql_num_rows($sql); $idact = ""; $idact1 = ""; $idact2 = ""; for ($i = 0; $i < $nombreligne; $i++) { if ($i == 0){ $idact = mysql_result($sql,$i,"id_acteur"); } else if ($i == 1){ $idact1 = mysql_result($sql,$i,"id_acteur"); } else if ($i == 2){ $idact2 = mysql_result($sql,$i,"id_acteur"); } } //1er acteur echo "<select name='acteur1' style='width:150px;'>"; $sql = mysql_query('Select * From acteurs Order by prenom_act ASC',$connexion); $nombreligne = mysql_num_rows($sql); if ($idact == ""){ echo "<OPTION value=''></OPTION>"; for ($i = 0; $i < $nombreligne; $i++) { $idact = mysql_result($sql,$i,"id_acteur"); $prenom = stripslashes(htmlentities(trim(mysql_result($sql,$i,"prenom_act")))); $nom = stripslashes(htmlentities(trim(mysql_result($sql,$i,"nom_act")))); echo "<OPTION value='$idact'>$prenom $nom</OPTION>"; } } else { for ($i = 0; $i < $nombreligne; $i++) { $idactbd = mysql_result($sql,$i,"id_acteur"); $prenom = stripslashes(htmlentities(trim(mysql_result($sql,$i,"prenom_act")))); $nom = stripslashes(htmlentities(trim(mysql_result($sql,$i,"nom_act")))); if ($idactbd == $idact) { echo "<OPTION value='$idactbd' selected>$prenom $nom</OPTION>"; } else { echo "<OPTION value='$idactbd'>$prenom $nom</OPTION>"; } } } echo '</select>';...J'espère que mon explication et mon code sont clairs.
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 <div id="mondiv3" class="hidden"> <form name="acteurs" method="post" action="index.php?page=film_modif"> <table border=0 style="width:250px; background-color:#CCFFCC"> <tr> <td style="height:40px" valign="top" align="center" colspan=2><font color="#969696"><b>Ajouter un acteur/une actrice</b></td> </tr> <tr> <td align="right">Nom : </td><td> <input type="text" name="plus_nomact" value=""></td> </tr> <tr> <td align="right">Prénom : </td><td> <input type="text" name="plus_prenomact" value=""></td> </tr> <tr> <td style="height:40px" align="center" colspan=2><input type="submit" name="valid4" value="Valider"> <input type="button" name="close" value="fermer" onclick="javascript:fermer('mondiv3');"></td></td> </tr> </table> </form> </div>
Partager