// deleteimage.php文件
<form action="dbdeleteimg.php" method="POST" enctype="multipart/form-data">
<select name="sub">
<?php
$con=mysqli_connect("localhost","root","","rwtp");
$sql="select * from image ";
$result=mysqli_query($con,$sql);
while($row=mysqli_fetch_array($result)){
$name=$row[0];
?>
<option value="<?php echo $name;?>" name="<?php echo $name; ?>" ><?php echo $name;?>
</option>
<?php
}
?>
</select>
<input type="submit"/>
</form>
以上文件是从数据库中获取代码并显示它的代码,在选择特定选项时,该值应该发送到另一个文件,即&#34; dbdeleteimg.php&#34;
// dbdeleteimg.php
<?php
$con =mysqli_connect("localhost","root","","rwtp");
if(!$con){
die("connection error");
}
$name=$sub=$type="";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
$type=$_POST["sub"];
}
$sql="select * from image where name='$name'";
$result=mysqli_query($con,$sql);
$row=mysqli_fetch_array($result);
$uploa=$row[3].$row[2];
unlink($uploa);
$sql="delete from image where name='$name'";
if(mysqli_query($con,$sql)){
//header('Location: option.php');
}else{
echo "error";
}
?>
enter image description here 现在上面的代码用于从服务器和数据库中删除图像。但在执行这些文件后,我收到了错误
undefined index:图片中显示的名称
注意:未定义的索引:第8行的C:\ xampp \ htdocs \ RWTP \ dbdeleteimg.php中的名称
警告:unlink():第15行的C:\ xampp \ htdocs \ RWTP \ dbdeleteimg.php中的参数无效