title: Update image in php and mysql database
body: <p>I have to update image in php and mysql database. I know I cannot set the value of file type input field but how do I achieve this? </p>
  
  <pre><code>//upload.php
  User Image&lt;input type="file" name="image" accept="image/png, image/jpeg, image/ico" value="&lt;?php echo $_GET['image'];?&gt;" /&gt;
  </code></pre>
  
  <pre><code>//upload query
  
      $id= $_GET['id'];
      $fname=$_GET['fname'];
      $lname=$_GET['lname'];
      $image=$_GET['image'];
    $sql = "UPDATE myGuest SET firstname='$fname', lastname='$lname', image='$image' WHERE id='$id'";  
      if($conn-&gt;query($sql))
      {
          echo "&lt;script&gt;alert('Record updated succesfully')&lt;/script&gt;";
          header("Refresh:0; url=view.php");
      }
      else{
          echo "Error: ".$sql."&lt;br&gt;".$conn-&gt;error;
  }
  </code></pre>
  
  <pre><code>//view.php
  &lt;td&gt;&lt;a href="update.php?id=&lt;?php echo $row['id']?&gt;&amp;fname=&lt;?php echo $row['firstname']?&gt;&amp;lname=&lt;?php echo $row['lastname']?&gt;&amp;image=&lt;?php echo $row['image']?&gt;"&gt;EDIT&lt;/a&gt;&lt;/td&gt;
  </code></pre>