<?php
	include ("../inc/koneksi.php");

	$nama = $_POST['nama'];
	$fas = $_POST['fas'];
	$ket = $_POST['ket'];
	$lat = $_POST['lat'];
	$lang = $_POST['lang'];
	
	$ikan1 = $_POST['ikan'];
	$ikan = implode(',', (array)$ikan1);
	
	$karang1 = $_POST['karang'];
	$karang = implode(',', (array)$karang1);
	
	$wrong = "";
	
	//upload foto
	$temp_foto = explode(".", $_FILES['foto']['name']);
	$newfilefoto = generateRandomString() . '.' . end($temp_foto);
	move_uploaded_file($_FILES['foto']['tmp_name'], "../img/bahari/" . $newfilefoto);

	//simpan ke dalam mhs
	$query = "INSERT INTO bahari (nama_bahari,fasilitas,keterangan,foto,lat,lang,ikan,karang) 
								VALUES ('$nama','$fas','$ket','$newfilefoto','$lat','$lang','$ikan','$karang')";		
	mysql_query($query) or die (mysql_error());


	if($wrong == "")
		$url = "index.php?act=bahari_input&ket=berhasil";
	else
		$url = "index.php?act=bahari_input&ket=$wrong";

	echo "<script language=\"javascript\">
		window.location='../$url';
	</script>";

?>