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
|
<?php
$hostdb = 'localhost';
$userdb = 'root';
$passdb = '';
$namedb = 'mfb';
try {
$conn = new PDO("mysql:host=".$hostdb."; dbname=".$namedb."", $userdb, $passdb, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
$conn->exec("SET CHARACTER SET utf8");
}
catch (PDOException $e) {
echo 'La base de donnée n\'est pas disponible';
}
if(isset($_POST['fournisseur_id'])){
$sql = 'DELETE FROM fournisseur WHERE fournisseur_id = :fournisseur_id';
$query = $conn->prepare( $sql );
if ($query == false) {
print_r($conn->errorInfo());
die ('Erreur prepare');
}
$res = $query->execute( array( ":fournisseur_id" => $_POST['fournisseur_id'] ) );
if ($res == false) {
print_r($query->errorInfo());
die ('Erreur execute');
}
header('Location:fournisseur.php');
exit();
}
?>
<form name="form" action="supprimefournisseur.php" method="POST" enctype="multipart/form-data" >
<fieldset>
<legend><em>Suppression d'un Fournisseur </em></legend>
<table align="center">
<tr>
<td>
<label for="ChampFournisseur">ID du Fournisseur:</label>
</td>
<td>
<select name="FournisseurID">
<?php
$req = $conn->query('SELECT * FROM fournisseur ORDER BY fournisseur_id');
while($donnees = $req->fetch())
{ ?>
<option value="<?php echo $donnees['fournisseur_id']; ?>"><?php echo $donnees['fournisseur_id']; ?></option>
<?php
} ?>
</select>
</td>
</tr>
<td></td>
<td>
<form action="supprimefournisseur.php" method="POST">
<input type="submit" name="bouton" value="OK" onclick="alert('Suppression avec succes');" style="background-color: black;
width: 100px;
height:30px;
border-radius: 6px;
color: white;
font-family: algerian;
text-align: center;" />
<a href='fournisseur.php'><input class='button' type='button' value='Annuler' style="background-color: black;
width: 100px;
height:30px;
border-radius: 6px;
color: white;
font-family: algerian;
text-align: center;"></a>
</form>
</td>
</table>
</fieldset>
</form>
</td>
</table> |
Partager