title: how to update text form with image
body: <p>how to update text form with image</p>
  
  <p>im trying to update text with image
  now this code working fine with text and also image update perfectly</p>
  
  <p>but image is not showing in edit from</p>
  
  <p>example  edit form </p>
  
  <ul>
  <li>Name:demo</li>
  <li>Father Name:demo</li>
  <li><p>address: demo</p>
  
  <p>Photo   - chose file- i want here image name like photo.jpg </p></li>
  </ul>
  
  <p>image is also there in database but not showing here in edit form </p>
  
  <p>how can i do this please tell me to fix this issue thanks</p>
  
  <p>this is form code</p>
  
  <pre><code>&lt;form action="" method="post" enctype="multipart/form-data"&gt;
       &lt;input type="hidden" name="id" value="&lt;?php echo $id; ?&gt;"/&gt;
       &lt;div&gt;
       &lt;p&gt;&lt;strong&gt;ID:&lt;/strong&gt; &lt;?php echo $id; ?&gt;&lt;/p&gt;
      &lt;div&gt;
         &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Teacher No:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input name="teacherno" type="text" value="&lt;?php echo $teacherno; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
         &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Teacher Name:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input name="name" type="text" value="&lt;?php echo $name; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
         &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Education:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input name="education" type="text" value="&lt;?php echo $education; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
         &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Father Name:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input name="fathername" type="text" value="&lt;?php echo $fathername; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
            &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Salary:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input name="salary" type="text" value="&lt;?php echo $salary; ?&gt;" size="50" /&gt;
          &lt;/p&gt;
          &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Date Of Birth :&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
            &lt;input name="age" type="text" value="&lt;?php echo $age; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
            &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Teach Class :&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
              &lt;input name="classteacher" type="text" value="&lt;?php echo $classteacher; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
         &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Phone No :&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input name="phone" type="text" value="&lt;?php echo $phone; ?&gt;"/&gt;
         &lt;/p&gt;
         &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Date Of Join :&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
           &lt;input id="fullDate" name="dateofjoin" type="text" value="&lt;?php echo $dateofjoin; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
          &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;Home Address :&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
             &lt;textarea name="address" cols="50"&gt;&lt;?php echo $address; ?&gt;&lt;/textarea&gt;
         &lt;/p&gt;
          &lt;p&gt;&lt;span class="style9"&gt;&lt;strong&gt;N.I.C No:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt;  *&lt;/strong&gt;
            &lt;input name="nic" type="text" value="&lt;?php echo $nic; ?&gt;" size="50" /&gt;
         &lt;/p&gt;
          &lt;span class="style9"&gt;&lt;strong&gt;Branch:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt; *&lt;/strong&gt;
          &lt;input name="branch" type="text" value="&lt;?php echo $branch; ?&gt;" size="50"&gt;
      &lt;span class="style9"&gt;&lt;strong&gt;Photo:&lt;/strong&gt;&lt;/span&gt;&lt;strong&gt; *&lt;/strong&gt;
                   &lt;input type="hidden" name="size" value="&lt;?php echo $photo; ?&gt;" size="50"&gt;
                  &lt;input type="file" name="photo"&gt; 
          &lt;br/&gt;
         &lt;p class="style1"&gt;* required&lt;/p&gt;
       &lt;input type="submit" name="submit" value="Submit"&gt;
       &lt;/div&gt;
       &lt;/form&gt; 
  </code></pre>
  
  <p>and this is php code</p>
  
  <pre><code>&lt;?php
   }
  
   //This is the directory where images will be saved
  $target = "images/";
  $target = $target . basename( $_FILES['photo']['name']);
  
  //This gets all the other information from the form
  
  $photo=($_FILES['photo']['name']);
  //Writes the photo to the server
  if(move_uploaded_file($_FILES['photo']['tmp_name'], $target))
  {
  
  //Tells you if its all ok
  echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory";
  }
  
  
   // connect to the database
   include('connect-db.php');
  
   // check if the form has been submitted. If it has, process the form and save it to the database
   if (isset($_POST['submit']))
   { 
   // confirm that the 'id' value is a valid integer before getting the form data
   if (is_numeric($_POST['id']))
   {
   // get form data, making sure it is valid
   $id = $_POST['id'];
   $teacherno = mysql_real_escape_string(htmlspecialchars($_POST['teacherno']));
   $name = mysql_real_escape_string(htmlspecialchars($_POST['name']));
   $education = mysql_real_escape_string(htmlspecialchars($_POST['education']));
   $salary = mysql_real_escape_string(htmlspecialchars($_POST['salary']));
   $classteacher = mysql_real_escape_string(htmlspecialchars($_POST['classteacher']));
   $dateofjoin = mysql_real_escape_string(htmlspecialchars($_POST['dateofjoin']));
   $nic = mysql_real_escape_string(htmlspecialchars($_POST['nic']));
   $address = mysql_real_escape_string(htmlspecialchars($_POST['address']));
   $age = mysql_real_escape_string(htmlspecialchars($_POST['age']));
   $fathername = mysql_real_escape_string(htmlspecialchars($_POST['fathername']));
   $phone = mysql_real_escape_string(htmlspecialchars($_POST['phone']));
   $branch = mysql_real_escape_string(htmlspecialchars($_POST['branch']));
   $photo = mysql_real_escape_string(htmlspecialchars($_FILES['photo']['name']));
  
   // check that firstname/lastname fields are both filled in
   if ($teacherno == '' || $name == '')
   {
   // generate error message
   $error = 'ERROR: Please fill in all required fields!';
  
   //error, display form
   renderForm($id, $teacherno, $name, $education, $salary, $classteacher, $dateofjoin, $nic, $address, $age, $fathername, $phone, $branch, $photo, $error);
   }
   else
   {
   // save the data to the database
   mysql_query("UPDATE teacher SET teacherno='$teacherno', name='$name', education='$education', salary='$salary', classteacher='$classteacher', dateofjoin='$dateofjoin', nic='$nic', address='$address', age='$age', phone='$phone', branch='$branch', photo='$photo' WHERE id='$id'")
   or die(mysql_error()); 
  
  
  
   // once saved, redirect back to the view page
   header("Location: view.php"); 
   }
   }
   else
   {
   // if the 'id' isn't valid, display an error
   echo 'Error!';
   }
   }
   else
   // if the form hasn't been submitted, get the data from the db and display the form
   {
  
   // get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0)
   if (isset($_GET['id']) &amp;&amp; is_numeric($_GET['id']) &amp;&amp; $_GET['id'] &gt; 0)
   {
   // query db
   $id = $_GET['id'];
   $result = mysql_query("SELECT * FROM teacher WHERE id=$id")
   or die(mysql_error()); 
   $row = mysql_fetch_array($result);
  
   // check that the 'id' matches up with a row in the databse
   if($row)
   {
  
   // get data from db
   $teacherno = $row['teacherno'];
   $name = $row['name']; 
   $education = $row['education']; 
   $salary = $row['salary']; 
   $classteacher = $row['classteacher']; 
   $dateofjoin = $row['dateofjoin']; 
   $nic = $row['nic']; 
   $address = $row['address']; 
   $age = $row['age']; 
   $fathername = $row['fathername']; 
   $phone = $row['phone']; 
   $branch = $row['branch']; 
   $photo = $row['photo']; 
  
  
   // show form
   renderForm($id, $teacherno, $name, $education, $salary, $classteacher, $dateofjoin, $nic, $address, $age, $fathername, $phone, $branch, $photo, '');
   }
   else
   // if no match, display result
   {
   echo "No results!";
   }
   }
   else
   // if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error
   {
   echo 'Error!';
   }
   }
  ?&gt;
  </code></pre>