我尝试在我的数据库中编辑图像但是我有一条错误消息:注意:未定义的索引:id
$id = $_GET['id'];
我能够添加图像,但我想知道如何更新图像???
<?php
// Connexion à la base de donnée
include('config_bd.php');
// Vérifications des inputs
if(isset($_POST['upload'])){
move_uploaded_file($_FILES["image"]["tmp_name"],"images/" .basename($_FILES['image']['name']));
$nom = htmlspecialchars($_POST['nom']);
$image = htmlspecialchars($_FILES['image']['name']);
if(empty($nom) || empty($image)){
if(empty($nom)) {
echo "<font color='red'>Le champ nom est vide.</font><br/>";
}
if(empty($image)) {
echo "<font color='red'>Le champ image est vide.</font><br/>";
}
}else{
$update = mysqli_query($mysqli, "UPDATE clubs SET nom='$nom',image='$image'WHERE id='$id'");
echo "<font color='green'>L'entrée a été enregistré!.";
echo "<br/><a href='view.php'>Consulter</a>";
}
}
$id = $_GET['id'];
$select = mysqli_query($mysqli, "SELECT * FROM clubs WHERE id='$id' ");
while($res = mysqli_fetch_array($select)){
echo "<div id='img_div'>";
echo "<p>" .$res['nom']."</p>";
echo "<img src='images/" .$res['image']."'>";
echo "</div>";
}
?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Titre de la page</title>
<link rel="stylesheet" href="style1.css">
<script src="script.js"></script>
</head>
<body>
<form method="post" action="edit.php" enctype="multipart/form-data">
<input type="text" name="nom" >
<input type="file" name="image"><br /><br />
<input type="submit" name="upload" value="Upload Image">
<input type="hidden" name="id" value=<?php echo $_GET['id'];?>>
</form>
</body>
</html>
非常感谢您的回答。