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 76 77
|
<html>
<head><title>Modifier un film</title></head>
<body>
<center>
<H1><FONT color=blue>Modifier un film </FONT></H1>
</center>
<?php
// Etablissement de la connexion avec le serveur
$connexion=mysql_connect("localhost","root","");
// Test de la connexion
if (!$connexion) {
echo "La connexion au serveur n'a pu être établie<BR>";
exit;
}
//Test de l'accès à la base
if (!mysql_select_db("videotheque",$connexion)) {
echo "L'accès à la base n'est pas permis<BR>";
exit;
}
$labels = array(
"titre"=>"titre:",
"annee"=>"annee:",
"resume"=>"resume:",
"duree"=>"duree:");
foreach($_POST as $champ => $valeur)
echo "<p><hr>";
echo "<h3>Modifiez le formulaire</h3>";
echo "<form action='Modification.php' method='POST'>
<table width='95%' border='0' cellspacing='0'
cellpadding='2'>\n";
foreach($labels as $champ=>$label)
echo "<tr>
<td align='right' <B>{$labels[$champ]}</br></td>
<td><input type='text' name='$champ'
</td>
</tr>";
echo "<tr>
<td colspan='2' style='text-align: center'>
<input type='submit' value='Modifier'>";
echo "</td></tr></table>
</form>";
exit();
{
$dataOk['idfilm'] = strip_tags(trim($_POST['idfilm']));
$dataOk['idfilm'] = ereg_replace("[)( .-]","",$dataOk['idfilm']);
$req = "UPDATE film SET titre='$dataOk[titre]',annee='$dataOk[annee]',resume='$dataOk[resume]',duree='$dataOk[duree]',
WHERE titre='$_POST[titre]'";
$result = mysql_query($connexion,$req)
or die ("Impossible: ".mysql_error($connexion));
}
?>
</body>
</html> |
Partager