我在图像点击代码上调用模型,用于图像点击是
<a data-toggle="modal" data-target="#editBox" href="file.php?id=<?php echo $path_id[$j] ;?>"> <?php echo "<img src=\"member_images/".$path[$j]."\" height='200' width='200' class='margin' />" ;?></a>
我将图片的ID传递给模型file.php
。如果我调用url/file.php?id=22
代码工作正常,但当我将其称为模型图像时,则不提交。
谁能告诉我哪里错了?
在下面的代码中,如果使用某些javascript更改了用户点击编辑图标图像,我将获得id并在模型中查看用户图像。如果用户更改,则应更新点击提交按钮图像,否则存储old_file_name
在$document
但是这个东西在模型中不起作用。
<?php
if(isset($_POST['Submit']))
{
if(isset($_GET['id']))
{
$id = $_GET['id'];
$queryrun=mysqli_query($db,"SELECT file_name FROM member_images WHERE id='$id' ");
$row=mysqli_fetch_object($queryrun);
if($row->file_name!== $document)
{
unlink("member_images/".$row->file_name);
}
$query = " UPDATE member_images SET file_name = '$document' where id = '$id' ";
$queryrun = mysqli_query($db,$query);
$_SESSION['msg'] = "Your Data Updated Successfully";
}
header("location:profiledemo.php");
}
?>
<div class="modal-body">
<form class="form-horizontal" role="form" method="POST">
<?php if(!empty($_GET['id'])){ ?>
<div class="form-group">
<input type="file" class="file1" name="image" accept="image/*" onchange="readURL(this);" style="display: none;" />
<input type="hidden" name="old_file_name" value="<?php if(isset($id)) echo $row->file_name;?>" >
</div>
<div class="form-group">
<img width="200px" height="200px" id="upfile" src="member_images/<?=$row->file_name;?>" style='position: relative;'>
<img src="img/edit.png" class="upfile1" style="cursor:pointer; position: absolute; top: 15px; left: 15px; z-index: '10'" />
</div>
<?php }?>
<div class="form-group">
<button type="submit" name="Submit" class="btn btn-default">Submit</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</form>
</div>