 <?php 
$table = $_POST["table"];
$db = $_POST["db"];
//connect to the database
$connect = mysql_connect("localhost","root","benk");
mysql_select_db("$db",$connect); //select the table
//
		
		
if ($_FILES[csv][size] > 0) {

    //get the csv file
    $file = $_FILES[csv][tmp_name];
    $handle = fopen($file,"r");
    
    //loop through the csv file and insert into database
    do {
        if ($data[0]) {
            mysql_query("INSERT INTO $table (t_nomor, t_nomorbriva, t_nama, t_alamat, t_pasal, t_bb, t_denda, t_biayaperkara, t_tglsidang, t_tglambil, t_asalsurat, t_hadirverstek ) VALUES
                (
                    '".addslashes($data[0])."',
                    '".addslashes($data[1])."',
					'".addslashes($data[2])."',
					'".addslashes($data[3])."',
					'".addslashes($data[4])."',
					'".addslashes($data[5])."',
					'".addslashes($data[6])."',
					'".addslashes($data[7])."',
					'".addslashes($data[8])."',
					'".addslashes($data[9])."',
                    '".addslashes($data[10])."',
					'".addslashes($data[11])."'
                )
            ");
        }
    } while ($data = fgetcsv($handle,1000,",","'"));
    //
echo "<b>Your file has been imported.</b><br><br>";
    //redirect
   // header('Location: index.php?success=1'); die;

}

?>
<?php // if (!empty($_GET[success]== '1')) { echo "<b>Your file has been imported.</b><br><br>"; } //generic success notice ?>