-2
<?php

$query="SELECT * FROM Products ORDER BY id ASC";
$result=mysqli_query($connect,$query);
$image_path = "";
if(mysqli_num_rows($result)>0)
{
    while($row=mysqli_fetch_array($result))
    {
        ?>

        <div class="item" style="background:white;solid lightgrey;box-shadow: 12px 12px 22px -10px #888888;">
            <form action="description.php" method="post" id="item">
                <div class="product">

                    <div class="product-thumb" name = "image" id ="image">
                        <?php echo '<img class="img-responsive img-fullwidth" src="data:image/jpeg;base64,'.base64_encode( $row["image"] ).'"/>' ?>

                        <input type="hidden" name='product_image' id="product_image"
                                value="<?php echo '<img class="img-responsive img-fullwidth" src="data:image/jpeg;base64,'.base64_encode( $row["image"] ).'"/>' ?>" />
                        //input closing tag is clashed  with img to closing tag

                    </div>
                    <div class="overlay">
                        <button name="add_to_cart" type="submit" class="btn btn-lg btn-dark btn-theme-colored btn btn-circled text-uppercase font-weight-5" href="shop-cart.html" >Add To Cart</button>

                    </div>

                </div>

        </div>
        </form>
        </div>
        <?php
    }
}
?>
aynber
  • 22,380
  • 8
  • 50
  • 63
Sagar Telangi
  • 93
  • 1
  • 1
  • 3

1 Answers1

0

I think the way your sending the image to the browser and then sending it back to the server is a bad idea. I can't tell you the proper way to do it since I don't know the context to what you are doing.

However, the solution to your problem is to escape the characters in the img tag using the htmlentities function like this:

<input 
     type="hidden" 
     name='product_image' 
     id="product_image"
     value="<?php echo htmlentities('<img class="img-responsive img-fullwidth" src="data:image/jpeg;base64,'.base64_encode( $row["image"] ).'"/>'); ?>" />
Ameen
  • 1,747
  • 3
  • 16
  • 31