title: php code of adding a record to database
body: <p>I am working on a control panel (admin pages) for a website. All the pages have the same code with little changes in the database table name and columns. All of them work fine, but one page doesn't work.</p>
  
  <p>This is its code....</p>
  
  <pre><code>&lt;?php
  include('connect.php');
  
  // read the input data
  $KTitle   = $_POST['Title'];
  $Kcontent = $_POST['content'];
  $ImgName  = $_FILES["file"]["name"];
  
  //get img extension
  $ImgExtension = substr($ImgName, (strlen($ImgName) - 4), strlen($ImgName));
  //check if it Gif, Bng, Jpg
  if ($ImgExtension == ".gif" || $ImgExtension == ".jpg" || $ImgExtension == ".png")
  { //get img name to rename it then readd the extinsion
      $ImgName      = substr($ImgName, 0, (strlen($ImgName) - 4));
      $storyImgName = $ImgName . "_" . $Title;
      $target       = "../CharacterImgs/" . $storyImgName . $ImgExtension;
      $target       = str_replace(" ", "_", $target);
  
      move_uploaded_file($_FILES['file']['tmp_name'], $target);
      mysql_query("INSERT INTO CharactersN (name,desc,img) VALUES ('$KTitle', '$Kcontent','$target')");
  
      echo "&lt;meta http-equiv=\"refresh\" content=\"3;URL=AddCharacterForm.php\"&gt;";
  }
  ?&gt;
  </code></pre>