Problème dans ma page de modification d'un enregistrement

Eléphanteau du PHP | 13 Messages

21 avr. 2005, 23:10

Bonjour à tous, :D

- J'ai fait une page de modification (Modif.php) d'un enregistrement de ma bdd (bdd_dvdperso).

1er FORMULAIRE :

- J'y ai inséré un 1er formulaire (formModifDvd / Action=Modif.php / Méth=GET).
- J'ai placé une Liste/Menu (titre) + 1 bouton "Sélectionner"


2ème FORMULAIRE :

- J'ai inséré un 2ème formulaire (form2 / Action=<?php echo $editFormAction; ?> / Méth=POST)
- J'ai placé des champs de texte + 1 bouton "Mettre à jour l'enregistrement"


MON PROBLEME :cry: :
Donc cette page Modif.php fonctionne mais mon problème c'est qu'en ouvrant cette page dans le navigateur, dans la fenêtre de la Liste/Menu, au lieu d'afficher simplement la liste de mes DVD à modifier, le code suivant s'affiche pour chaque DVD :
Notice: Undefined index: titre in c:\program files\easyphp1-8\wwww\sitedvdray\dvd\modif.php on line 185 >1001 pattes
Notice: Undefined index: titre in c:\program files\easyphp1-8\wwww\sitedvdray\dvd\modif.php on line 185 >Dinosaure
Notice: Undefined index: titre in c:\program files\easyphp1-8\wwww\sitedvdray\dvd\modif.php on line 185 >Titanic

Etc...

Ca fait une heure que je cherche en vain, j'y comprends rien :x !


Code de la ligne 185 de ma page Modif.php :

Code : Tout sélectionner

<option value="<?php echo $row_ListeDvdModif['titre']?>"<?php if (!(strcmp($row_ListeDvdModif['titre'], $_GET['titre']))) {echo "SELECTED";} ?>><?php echo $row_ListeDvdModif['titre']?></option>

Code de ma page Modif.php :

Code : Tout sélectionner

<?php require_once('../Connections/connexionDvdRay.php'); ?> <?php function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") { $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue; switch ($theType) { case "text": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "long": case "int": $theValue = ($theValue != "") ? intval($theValue) : "NULL"; break; case "double": $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL"; break; case "date": $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL"; break; case "defined": $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue; break; } return $theValue; } $editFormAction = $_SERVER['PHP_SELF']; if (isset($_SERVER['QUERY_STRING'])) { $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE listedvd SET ID=%s, `acteursactrices`=%s, realisateur=%s, scénariste=%s, musique=%s, annee=%s, pays=%s, resume=%s, disque=%s, genre=%s, duree=%s WHERE titre=%s", GetSQLValueString($_POST['ID'], "int"), GetSQLValueString($_POST['acteursactrices'], "text"), GetSQLValueString($_POST['realisateur'], "text"), GetSQLValueString($_POST['scénariste'], "text"), GetSQLValueString($_POST['musique'], "text"), GetSQLValueString($_POST['annee'], "date"), GetSQLValueString($_POST['pays'], "text"), GetSQLValueString($_POST['resume'], "text"), GetSQLValueString($_POST['disque'], "int"), GetSQLValueString($_POST['genre'], "text"), GetSQLValueString($_POST['duree'], "date"), GetSQLValueString($_POST['titre'], "text")); mysql_select_db($database_connexionDvdRay, $connexionDvdRay); $Result1 = mysql_query($updateSQL, $connexionDvdRay) or die(mysql_error()); $updateGoTo = "Liste.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) { $updateSQL = sprintf("UPDATE listedvd SET titre=%s, acteursactrices=%s, realisateur=%s, scénariste=%s, musique=%s, annee=%s, pays=%s, resume=%s, disque=%s, genre=%s, duree=%s WHERE ID=%s", GetSQLValueString($_POST['titre'], "text"), GetSQLValueString($_POST['acteursactrices'], "text"), GetSQLValueString($_POST['realisateur'], "text"), GetSQLValueString($_POST['scnariste'], "text"), GetSQLValueString($_POST['musique'], "text"), GetSQLValueString($_POST['annee'], "date"), GetSQLValueString($_POST['pays'], "text"), GetSQLValueString($_POST['resume'], "text"), GetSQLValueString($_POST['disque'], "int"), GetSQLValueString($_POST['genre'], "text"), GetSQLValueString($_POST['duree'], "date"), GetSQLValueString($_POST['ID'], "int")); mysql_select_db($database_connexionDvdRay, $connexionDvdRay); $Result1 = mysql_query($updateSQL, $connexionDvdRay) or die(mysql_error()); $updateGoTo = "Liste.php"; if (isset($_SERVER['QUERY_STRING'])) { $updateGoTo .= (strpos($updateGoTo, '?')) ? "&" : "?"; $updateGoTo .= $_SERVER['QUERY_STRING']; } header(sprintf("Location: %s", $updateGoTo)); } mysql_select_db($database_connexionDvdRay, $connexionDvdRay); $query_ListeDvdModif = "SELECT titre FROM listedvd ORDER BY titre ASC"; $ListeDvdModif = mysql_query($query_ListeDvdModif, $connexionDvdRay) or die(mysql_error()); $row_ListeDvdModif = mysql_fetch_assoc($ListeDvdModif); $totalRows_ListeDvdModif = mysql_num_rows($ListeDvdModif); $colname_rsModifDvd = "1"; if (isset($_GET['titre'])) { $colname_rsModifDvd = (get_magic_quotes_gpc()) ? $_GET['titre'] : addslashes($_GET['titre']); } mysql_select_db($database_connexionDvdRay, $connexionDvdRay); $query_rsModifDvd = sprintf("SELECT * FROM listedvd WHERE titre = '%s'", $colname_rsModifDvd); $rsModifDvd = mysql_query($query_rsModifDvd, $connexionDvdRay) or die(mysql_error()); $row_rsModifDvd = mysql_fetch_assoc($rsModifDvd); $totalRows_rsModifDvd = mysql_num_rows($rsModifDvd); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html><!-- InstanceBegin template="/Templates/AccueilDvd.dwt.php" codeOutsideHTMLIsLocked="false" --> <head> <!-- InstanceBeginEditable name="doctitle" --> <title>Modiffication DVD</title> <!-- InstanceEndEditable --><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right: 0px; margin-bottom: 0px; background-color: #000000; } .Style8 { color: #999999; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; } .Style9 { color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px; } .Style15 {font-size: 14px; color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-weight: bold; } .Style17 {color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; } --> </style> <!-- InstanceBeginEditable name="head" --> <style type="text/css"> <!-- .Style19 {font-size: 12px} --> </style> <style type="text/css"> <!-- .Style20 {color: #FEFD0C} --> </style> <table width="800" height="300" border="0" cellpadding="0" cellspacing="0"> <tr> <th align="center" valign="top" scope="col"><form action="Modif.php" method="get" name="formModifDvd" id="formModifDvd"> <table width="400" border="0" cellspacing="0" cellpadding="0"> <tr> <th height="50" scope="col"><table width="190" height="25" border="0" cellpadding="0" cellspacing="0" bgcolor="#A21C1D"> <tr> <th scope="col"><span class="Style18 Style19 CSS_DvdCdRay Style19 Style20">MODIFICATION D'UN DVD </span></th> </tr> </table></th> </tr> <tr> <th scope="col"><select name="titre" id="titre"> <?php do { ?> <option value="<?php echo $row_ListeDvdModif['titre']?>"<?php if (!(strcmp($row_ListeDvdModif['titre'], $_GET['titre']))) {echo "SELECTED";} ?>><?php echo $row_ListeDvdModif['titre']?></option> <?php } while ($row_ListeDvdModif = mysql_fetch_assoc($ListeDvdModif)); $rows = mysql_num_rows($ListeDvdModif); if($rows > 0) { mysql_data_seek($ListeDvdModif, 0); $row_ListeDvdModif = mysql_fetch_assoc($ListeDvdModif); } ?> </select></th> </tr> <tr> <td height="50" align="center" valign="middle"><input type="submit" name="Submit" value="Sélectionner"></td> </tr> </table> </form> <form action="<?php echo $editFormAction; ?>" method="post" name="form2" id="form2"> <table align="center"> <tr valign="baseline"> <td nowrap align="right">Titre:</td> <td><input type="text" name="titre" value="<?php echo $row_rsModifDvd['titre']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Acteurs actrices:</td> <td><input name="acteursactrices" type="text" id="acteursactrices" value="<?php echo $row_rsModifDvd['acteursactrices']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Realisateur:</td> <td><input type="text" name="realisateur" value="<?php echo $row_rsModifDvd['realisateur']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Scénariste:</td> <td><input name="scénariste" type="text" id="scénariste" value="<?php echo $row_rsModifDvd['scénariste']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Musique:</td> <td><input type="text" name="musique" value="<?php echo $row_rsModifDvd['musique']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Annee:</td> <td><input type="text" name="annee" value="<?php echo $row_rsModifDvd['annee']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Pays:</td> <td><input type="text" name="pays" value="<?php echo $row_rsModifDvd['pays']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Resume:</td> <td><input type="text" name="resume" value="<?php echo $row_rsModifDvd['resume']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Disque:</td> <td><input type="text" name="disque" value="<?php echo $row_rsModifDvd['disque']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Genre:</td> <td><input type="text" name="genre" value="<?php echo $row_rsModifDvd['genre']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">Duree:</td> <td><input type="text" name="duree" value="<?php echo $row_rsModifDvd['duree']; ?>" size="32"></td> </tr> <tr valign="baseline"> <td nowrap align="right">&nbsp;</td> <td><input type="submit" value="Mettre à jour l'enregistrement"></td> </tr> </table> <input type="hidden" name="ID" value="<?php echo $row_rsModifDvd['ID']; ?>"> <input type="hidden" name="MM_update" value="form1"> <input type="hidden" name="ID" value="<?php echo $row_rsModifDvd['ID']; ?>"> </form> <p>&nbsp;</p></th> </tr> </table> <!-- InstanceEndEditable --> </body><!-- InstanceEnd --> <p>&nbsp;</p> </html> <?php mysql_free_result($ListeDvdModif); mysql_free_result($rsModifDvd); ?>

Voilà, j'espère que j'ai été clair et pas trop long :oops: .

Merci d'avance pour votre aide, :wink:
Adam
EasyPhp v1.8.0.1 - Dreamweaver MX 2004 - Manuel : "PHP/MySQL avec Dreamweaver MX 2004" de Jean-Marie Defrance (Ed. EYROLLES)

Eléphant du PHP | 139 Messages

22 avr. 2005, 01:01

ça vient de ton $_GET['titre']

suggestion :

au début de ton script, fais par exemple :
if (isset($_GET['titre'])) { $titre=$_GET['titre'] }else{ $titre="";}
et remplace tous tes $_GET['titre'] par $titre

ça évite les problèmes par la suite

Modérateur PHPfrance
Modérateur PHPfrance | 6373 Messages

22 avr. 2005, 01:44

je croyais que tu devais le faire tout seul comme un grand ton formulaire de modification de DVD [-( ;)

en plus avec ton code à toi tu posterai pas 700 lignes d'un coup que seules de rares personnes auront le courage de lire... :)