<?php
    include('loginsession.php');
    error_reporting(E_ALL);
    $filename = __FILE__;  //---Nama file saat ini
    if (strlen(__FILE__) > 48) {$filename = substr(__FILE__, 48);}
    $save = mysqli_query($conn, "INSERT INTO novia_abc_user_logs (userid,filename) VALUES ('$userini_id','$filename')");
//-------------

$mr=  $_GET['id'];
//$mr=  $_POST['mr']; 
$nama=  $_POST['name']; 
$phone_wa=  $_POST['phone_wa'];
$phone_home=  $_POST['phone_home']; 
$street_address=  $_POST['street_address'];
$kelurahan=  $_POST['kelurahan']; 
$kecamatan=  $_POST['kecamatan']; 
$city=  $_POST['city']; 
$state=  $_POST['state']; 
$kode_pos=  $_POST['kode_pos']; 
$email=  $_POST['email']; 
$firstcome=  $_POST['firstcome'];
$birthday=  $_POST['birthday']; $height=  $_POST['height']; 
$note=  $_POST['note'];
$password = $_POST['password'];
if ( $userini_id == "3"){
    $password = 000;
}

    if(empty($nama)){    //jika nama kosong maka muncul pesan
        echo "<script>alert('Nama masih Kosong');document.location='biodata-new.php'</script>";
    } 
    //else if(empty($street_address)){    //jika nama kosong maka muncul pesan
    //    echo "<script>alert('Alamat masih Kosong');document.location='biodata-new.php'</script>";
    //} 
	else if ( $password != 000 ) {
        echo "<script>alert('Password Anda Salah');document.location='biodata-new.php'</script>";
	} else { $save = mysqli_query($conn, "INSERT INTO novia_abc_biodata (id, mr, name, phone_wa, phone_home, street_address, kelurahan, kecamatan, city, state, kode_pos, email, firstcome, birthday, height, note )
			 VALUES ('$mr','$mr','$nama','$phone_wa','$phone_home','$street_address','$kelurahan','$kecamatan', '$city', '$state', '$kode_pos', '$email', '$firstcome', '$birthday', '$height', '$note')");

		if($save){ //jika update berhasil maka muncul pesan dan menuju ke halaman produk
			echo "<script>document.location='biodata.php?id=$mr'</script>";
		} else {  //jika update gagal maka muncul pesan
			 echo "<script>alert('Proses simpan gagal, coba kembali');document.location='index.php'</script>";
    }
}
?>
