Skip to main content

Double Inset dua database

<?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

Popular posts from this blog

Menggenerate nomor id

<?php //config $database = "dopo"; $tabel = "po"; $kolom_generate ="id"; $kolom_referensi = "id"; /* Database connection start */ $servername = "localhost"; $username = "root"; $password = ""; $dbname = $database; $mysqli = mysqli_connect($servername, $username, $password, $dbname) or die("Connection failed: " . mysqli_connect_error()); $q1 = "select * from $tabel order by $kolom_referensi DESC"; /* Database connection end */ echo '<table>'; // connect to the database // number of results to show per page $per_page = 10000; // figure out the total pages in the database if ($result = $mysqli->query($q1)) { if ($result->num_rows != 0) { $total_results = $result->num_rows; // ceil() returns the next highest integer value by rounding up value if necessary $total_pages = ceil($total_results / $per_page); // check if the 'page' variab...

Membuat Codeigniter PDF di CPANEL

1. Download FPDF dan copykan di folder application/thirdparty/pdf/ 2. Buat file Fpdf_gen.php di libraries. <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Fpdf_gen { public function __construct() {  require_once APPPATH.'third_party/fpdf/fpdf-1.8.php'; define('FPDF_FONTPATH', APPPATH.'third_party/fpdf/font/'); $pdf = new FPDF(); $pdf->AddPage(); $CI =& get_instance(); $CI->fpdf = $pdf; } public function Footer() { $this->fpdf->SetY(-15); $this->fpdf->SetFont('Arial','I',8); $this->fpdf->SetTextColor(128); $this->fpdf->Cell(0,10,'Page ',0,0,'C'); } } 3. Buat file pdf.php di controller <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); defined('BASEPATH') OR exit('No direct script access allowed'); class Pdf extends CI_Controller {   public f...

Nusoap Web Service

hellowsdl.php ---> di server <?php // Pull in the NuSOAP code require_once('lib/nusoap.php'); // Create the server instance $server = new soap_server(); // Initialize WSDL support $server->configureWSDL('hellowsdl', 'urn:hellowsdl'); // Register the method to expose $server->register('hello',                // method name     array('name' => 'xsd:string'),        // input parameters     array('return' => 'xsd:string'),    // output parameters     'urn:hellowsdl',                    // namespace     'urn:hellowsdl#hello',                // soapaction     'rpc',       ...