<?php
include_once("../include/main.inc.php");
//check_session('MyCpanel','index.php');
$redirect="manage_admission.php";
?>
<?php
if(isset($_POST["submit"]))
{
  $i=0;
          $file = $_FILES['file']['tmp_name'];
          $handle = fopen($file, "r");
          $c = 0;
          while(($filesop = fgetcsv($handle, 1000, ",")) !== false)
                    {
          $product_title = $filesop[0];
          $product_cat = $filesop[1];
		  $prodcut_status=$filesop[2];
		  $product_Gender = $filesop[3];
          $sname = $filesop[4];
          $sfname = $filesop[5];
          $sclass = $filesop[6];
			  if($i>0) {
          $sql = "insert into adtest_tbl(product_title,product_cat,prodcut_status,product_Gender,sname,sfname,sclass) values ('$product_title','$product_cat','$prodcut_status','$product_Gender','$sname','$sfname','$sclass')";
          $stmt = mysql_query($sql);
         $c = $c + 1;
			  }
			    $i++;
			  }

            if($sql){
               echo "sucess";
				header("Location: ".SITE_ADMIN_URL."/".$redirect);
             } 
		 else
		 {
            echo "Sorry! Unable to impo.";
          }

}
?>
<!DOCTYPE html>
<html>
<body>
<form enctype="multipart/form-data" method="post" role="form">
    <div class="form-group">
        <label for="exampleInputFile">File Upload</label>
        <input type="file" name="file" id="file" size="150" required>
        <p class="help-block">Only CSV File Import.</p>
    </div>
    <button type="submit" class="btn btn-default" name="submit" value="submit">Upload</button>
</form>
	<br>
	<br>
	 <button type="button" class="btn btn-default"><a style="text-decoration:none;color:red;" href="<?=SITE_URL_PATH;?>/images/result-upload.csv" target="_blank" download>Download Sample File</a></button>

</body>
</html>