<?php
include('../headertop.php');
include('../db.php');
//include('../datepicker.php');

$disp = '';
$pagetitle = 'Add New Work Category';

if(!isset($_POST['addworktype2submit']))
{
echo '<meta http-equiv="refresh" content="0;URL=addworktype.php">';
exit;
}


if ($_FILES['uploadedfile']['error'] == UPLOAD_ERR_OK && is_uploaded_file($_FILES['uploadedfile']['tmp_name']) && $_FILES["uploadedfile"]["type"] == "text/plain"  ) 
{ 
$f = fopen($_FILES['uploadedfile']['tmp_name'], "r");
while(!feof($f)){
    $line = fgets($f);
    $q = "insert into work_type(work_type) values('$line')";
	mysqli_query($dbcon,$q) or die(mysqli_error());
}
fclose($f);
$sm = 'Work Type data saved in database from file';
  //echo file_get_contents($_FILES['uploadedfile']['tmp_name']); 
}
else
$sm = 'Could not upload or read file';

echo '<meta http-equiv="refresh" content="0;URL=addworktype.php?sm='.$sm.'">';
