title: how to replace image in php?
body: <p>I used this code for replacing an image, but the image is not uploaded in upload folder, but the database is updated.  I need to replace the image.</p>
  
  <pre><code>&lt;?php
  require("header.php");
  
  $patientid = $_POST['patientid'];
  $pname = $_POST['pname'];
  $fname = $_POST['fname'];
  $address = $_POST['address'];
  
  if(!$pname || !$address) {
      echo "&lt;center&gt;";
      echo "Fillup required fields&lt;br&gt;&lt;br&gt;";
      echo "&lt;/center&gt;";
  }
  else {
      $ran2 = $patientid;
      $new_name2 = $ran2."b";
      $new_file_name2 = $new_name2."."."jpg";
      $path = "./members/".$new_file_name2;
  
      $copied = move_uploaded_file($_FILES['img_name']['tmp_name'], $path);
  
      if ($copied) {
          $sql = mysql_query("UPDATE info_store 
          SET pname='$pname', fname='$fname', address='$address', image1='$new_file_name2'
          WHERE patientid='$patientid'");
          return true;
      }
      else {
          echo "&lt;center&gt;&lt;h3&gt;There are An Errors In Uploading!&lt;/h3&gt;&lt;/center&gt;";
          return false;
      }
  }
  ?&gt;
  </code></pre>
  
  <p>Please give me a solution.</p>