Update query from the database:
<?php
    include 'dpconnection.php';
    $uid=$_REQUEST['upid'];
    if (isset($_POST['update'])) {
    $category= $_POST['category'];
    $pname= $_POST['pname'];
    $parea= $_POST['parea'];
    $pPrices= $_POST['pPrices'];
    $pAddress= $_POST['pAddress'];
                $filename = $_FILES['new_image']['name'] ;
                $tempname = $_FILES['new_image']['tmp_name'] ; 
                $filesize = $_FILES['new_image']['size'] ;
                $fileextension = explode('.', $filename) ;
                $fileextension = strtolower(end($fileextension));
                $newfilename = uniqid().'images'.'.'.$fileextension ;
                $path = "media/".$newfilename ;
                $sql = mysqli_query($conn,"UPDATE product SET c_id='$category', p_name='$pname', p_area='$parea', p_prices='$pPrices',p_address='$pAddress', p_thumb_image='$path' WHERE p_id='$uid'");
                if (move_uploaded_file($tempname, $path) && $sql)  {
                    echo "<script>alert('Record Updated successfully');</script>";
                    echo "<script>location.href = 'adminViewProduct.php';</script>";
                } else {
                    echo "Error updating record: " . $conn->error;
                }
}
?>
Image not deleting from folder, i have two if statement but just one else statement so it looks like i am missing something but i really don't know what i am missing.
This is form:
<div class="form-group">
<label>Address</label>
<input class="form-control" type="text" name="pAddress" value="<?php echo $row1['p_address'];?>">
</div>
<div class="form-group">
<label>Thumb Image</label>
<input type="file" name="new_image" class="form-control">
<input  class="form-control" type="hidden" name="pimage" value="<?php echo $row1['p_thumb_image'];?>">
                            
<img class="float-left" src="<?php echo $row1['p_thumb_image'];?>" width="100px;"><br><br>
</div>
<div class="form-group text-center">
<input class="btn btn-primary" type="submit" name="update" value="Update">
</div>
</form>
 
     
    