<?php
 //menggunakan class phpExcelReader
 include "reader.php";
 
$host='localhost';
$username='root';
$password='';
$database='mhs';
mysql_connect($host,$username,$password);
mysql_select_db($database);
 
 $data = new Spreadsheet_Excel_Reader($_FILES['userfile']['tmp_name']);
 $baris = $data->rowcount($sheet_index=0);
 
 for ($i=2; $i<=$baris; $i++) {
 $NO = $data->val($i,1);
 $NAMA = $data->val($i,2);
 $JK = $data->val($i,3);
 $NIDN = $data->val($i,4);
 $NIK = $data->val($i,5);
 $JURUSAN = $data->val($i,6);
 $PANGKAT = $data->val($i,7);
 $JABATAN = $data->val($i,8);
 $GOL = $data->val($i,9);

 
 $Nama2 = str_replace(",",".",$NAMA);

$result = mysql_query("select NIP from tbdosen where NIP = '".$NIK."'");
$num_rows = mysql_num_rows($result);

	if ($num_rows == 0){
	
	 $query = "INSERT INTO tbdosen (Nama, JK, NIDN, NIP, JURUSAN, PANGKAT, JABATAN, GOL) values ('$NAMA', '$JK', '$NIDN', '$NIK', '$JURUSAN', '$PANGKAT', '$JABATAN', '$GOL')";
	 $hasil = mysql_query($query);
	 
	}
}
	echo "<script>window.location='".$base."data-dosen'</script>"
 
?>