<?php
//mysql_connect
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "surat";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
//postgresql
$host = "localhost";
$user = "postgres";
$pass = "........";
$db = "dikti";
$con = pg_connect("host=$host dbname=$db user=$user password=$pass")
or die ("Could not connect to server\n");
//ambil data
$nomor= "";
$tanggal_agenda = $_POST["tanggal_agenda"];
function rubah_tgl_th($th)
{
$exp = explode(' ',$th);
if (count($exp) == 3)
{
$th =$exp[2];
}
return $th;
}
//rubah tanggal ke bulan ----
function rubah_tgl_bl($bl)
{
$exp = explode(' ',$bl);
if (count($exp) == 3)
{
$bl =$exp[1];
}
return $bl;
}
//rubah tanggal ke hari ----
function rubah_tgl_hr($hr)
{
$exp = explode(' ',$hr);
if (count($exp) == 3)
{
$hr =$exp[0];
}
return $hr;
}
$tgta= rubah_tgl_hr($tanggal_agenda);
$blta= rubah_tgl_bl($tanggal_agenda);
$thta= rubah_tgl_th($tanggal_agenda);
$jamta= "";
$na= $_POST["na"];
$na1= $_POST["na1"];
$na2= $_POST["na2"];
$na3= $_POST["na3"];
$tanggal_surat_masuk = $_POST["tanggal_surat_masuk"];
$tgts= rubah_tgl_hr($tanggal_surat_masuk);
$blts= rubah_tgl_bl($tanggal_surat_masuk);
$thts= rubah_tgl_th($tanggal_surat_masuk);
$ns= $_POST["ns"];
$klm= $_POST["klm"];
$lokasi= $_POST["lokasi"];
$asr= $_POST["asr"];
$hl= $_POST["hl"];
$kpd= $_POST["kpd"];
$tgldis= $_POST["tgldis"];
$tgldis1= $_POST["tgldis1"];
$jamds= $_POST["jamds"];
$jamds1= $_POST["jamds1"];
$ds1= $_POST["ds1"];
$ds2= $_POST["ds2"];
$ds3= $_POST["ds3"];
$ds4= $_POST["ds4"];
$ds5= $_POST["ds5"];
$ids1= $_POST["ids1"];
$ids2= $_POST["ids2"];
$ids3= $_POST["ids3"];
$ids4= $_POST["ids4"];
$ids5= $_POST["ids5"];
$td1= $_POST["td1"];
$tgtd1= $_POST["tgtd1"];
$td2= $_POST["td2"];
$tgtd2= $_POST["tgtd2"];
$td3= $_POST["td3"];
$tgtd3= $_POST["tgtd3"];
$td4= $_POST["td4"];
$tgtd4= $_POST["tgtd4"];
$td5= $_POST["td5"];
$tgtd5= $_POST["tgtd5"];
$ntd1= $_POST["ntd1"];
$ntd2= $_POST["ntd2"];
$ntd3= $_POST["ntd3"];
$ntd4= $_POST["ntd4"];
$ntd5= $_POST["ntd5"];
//sql masuk
$sql = "INSERT INTO `dpa2016` VALUES ('$nomor', '$tgta', '$blta', '$thta', '$jamta', '$na', '$na1', '$na2', '$na3', '$tgts', '$blts', '$thts', '$ns', '$klm', '$lokasi', '$asr', '$hl', '$kpd', '$tgldis', '$tgldis1', '$jamds', '$jamds1', '$ds1', '$ds2', '$ds3', '$ds4', '$ds5', '$ids1', '$ids2', '$ids3', '$ids4', '$ids5', '$td1', '$tgtd1', '$td2', '$tgtd2', '$td3', '$tgtd3', '$td4', '$tgtd4', '$td5', '$tgtd5', '$ntd1', '$ntd2', '$ntd3', '$ntd4', '$ntd5')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
//sql postgre
$sql_postgre = "INSERT INTO surat_masuk VALUES ('$nomor', '$tgta', '$blta', '$thta', '$jamta', '$na', '$na1', '$na2', '$na3', '$tgts', '$blts', '$thts', '$ns', '$klm', '$lokasi', '$asr', '$hl', '$kpd', '$tgldis', '$tgldis1', '$jamds', '$jamds1', '$ds1', '$ds2', '$ds3', '$ds4', '$ds5', '$ids1', '$ids2', '$ids3', '$ids4', '$ids5', '$td1', '$tgtd1', '$td2', '$tgtd2', '$td3', '$tgtd3', '$td4', '$tgtd4', '$td5', '$tgtd5', '$ntd1', '$ntd2', '$ntd3', '$ntd4', '$ntd5')";
$result = pg_query($con, $sql_postgre);
pg_close($con);
mysqli_close($conn);
header("location: surat_masuk_internal.php");
?>
//mysql_connect
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "surat";
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
//postgresql
$host = "localhost";
$user = "postgres";
$pass = "........";
$db = "dikti";
$con = pg_connect("host=$host dbname=$db user=$user password=$pass")
or die ("Could not connect to server\n");
//ambil data
$nomor= "";
$tanggal_agenda = $_POST["tanggal_agenda"];
function rubah_tgl_th($th)
{
$exp = explode(' ',$th);
if (count($exp) == 3)
{
$th =$exp[2];
}
return $th;
}
//rubah tanggal ke bulan ----
function rubah_tgl_bl($bl)
{
$exp = explode(' ',$bl);
if (count($exp) == 3)
{
$bl =$exp[1];
}
return $bl;
}
//rubah tanggal ke hari ----
function rubah_tgl_hr($hr)
{
$exp = explode(' ',$hr);
if (count($exp) == 3)
{
$hr =$exp[0];
}
return $hr;
}
$tgta= rubah_tgl_hr($tanggal_agenda);
$blta= rubah_tgl_bl($tanggal_agenda);
$thta= rubah_tgl_th($tanggal_agenda);
$jamta= "";
$na= $_POST["na"];
$na1= $_POST["na1"];
$na2= $_POST["na2"];
$na3= $_POST["na3"];
$tanggal_surat_masuk = $_POST["tanggal_surat_masuk"];
$tgts= rubah_tgl_hr($tanggal_surat_masuk);
$blts= rubah_tgl_bl($tanggal_surat_masuk);
$thts= rubah_tgl_th($tanggal_surat_masuk);
$ns= $_POST["ns"];
$klm= $_POST["klm"];
$lokasi= $_POST["lokasi"];
$asr= $_POST["asr"];
$hl= $_POST["hl"];
$kpd= $_POST["kpd"];
$tgldis= $_POST["tgldis"];
$tgldis1= $_POST["tgldis1"];
$jamds= $_POST["jamds"];
$jamds1= $_POST["jamds1"];
$ds1= $_POST["ds1"];
$ds2= $_POST["ds2"];
$ds3= $_POST["ds3"];
$ds4= $_POST["ds4"];
$ds5= $_POST["ds5"];
$ids1= $_POST["ids1"];
$ids2= $_POST["ids2"];
$ids3= $_POST["ids3"];
$ids4= $_POST["ids4"];
$ids5= $_POST["ids5"];
$td1= $_POST["td1"];
$tgtd1= $_POST["tgtd1"];
$td2= $_POST["td2"];
$tgtd2= $_POST["tgtd2"];
$td3= $_POST["td3"];
$tgtd3= $_POST["tgtd3"];
$td4= $_POST["td4"];
$tgtd4= $_POST["tgtd4"];
$td5= $_POST["td5"];
$tgtd5= $_POST["tgtd5"];
$ntd1= $_POST["ntd1"];
$ntd2= $_POST["ntd2"];
$ntd3= $_POST["ntd3"];
$ntd4= $_POST["ntd4"];
$ntd5= $_POST["ntd5"];
//sql masuk
$sql = "INSERT INTO `dpa2016` VALUES ('$nomor', '$tgta', '$blta', '$thta', '$jamta', '$na', '$na1', '$na2', '$na3', '$tgts', '$blts', '$thts', '$ns', '$klm', '$lokasi', '$asr', '$hl', '$kpd', '$tgldis', '$tgldis1', '$jamds', '$jamds1', '$ds1', '$ds2', '$ds3', '$ds4', '$ds5', '$ids1', '$ids2', '$ids3', '$ids4', '$ids5', '$td1', '$tgtd1', '$td2', '$tgtd2', '$td3', '$tgtd3', '$td4', '$tgtd4', '$td5', '$tgtd5', '$ntd1', '$ntd2', '$ntd3', '$ntd4', '$ntd5')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
//sql postgre
$sql_postgre = "INSERT INTO surat_masuk VALUES ('$nomor', '$tgta', '$blta', '$thta', '$jamta', '$na', '$na1', '$na2', '$na3', '$tgts', '$blts', '$thts', '$ns', '$klm', '$lokasi', '$asr', '$hl', '$kpd', '$tgldis', '$tgldis1', '$jamds', '$jamds1', '$ds1', '$ds2', '$ds3', '$ds4', '$ds5', '$ids1', '$ids2', '$ids3', '$ids4', '$ids5', '$td1', '$tgtd1', '$td2', '$tgtd2', '$td3', '$tgtd3', '$td4', '$tgtd4', '$td5', '$tgtd5', '$ntd1', '$ntd2', '$ntd3', '$ntd4', '$ntd5')";
$result = pg_query($con, $sql_postgre);
pg_close($con);
mysqli_close($conn);
header("location: surat_masuk_internal.php");
?>
Comments
Post a Comment