<?php

function open_connection(){
    $host = "localhost";
    $username = "root";
    $pass = "";
    $dbname = "pre_school";
    
    $koneksi = mysqli_connect($host, $username, $pass, $dbname);
    
    if(mysqli_connect_errno()){
        die("Gagal melakukan koneksi ke MYSQL :" . mysqli_connect_error());

    }

    return $koneksi;
}

// Mencatat aktivitas ke tabel log_aktivitas (dipakai di dashboard "Aktivitas Terbaru")
function catat_log($con, $deskripsi, $tipe){
    $deskripsi = mysqli_real_escape_string($con, $deskripsi);
    $tipe = mysqli_real_escape_string($con, $tipe);
    mysqli_query($con, "INSERT INTO log_aktivitas (deskripsi, tipe) VALUES ('$deskripsi', '$tipe')");
}

?>