| Server IP : 127.0.0.1 / Your IP : 192.168.99.1 Web Server : Apache/2.4.35 (Win64) OpenSSL/1.1.1b mod_fcgid/2.3.9 System : Windows NT WIN-JEJMB9EN0L0 10.0 build 14393 (Windows Server 2016) AMD64 User : Administrator ( 0) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /bpkd_/admin/config/ |
Upload File : |
<?php
// Database configuration
define('DB_HOST', 'localhost');
define('DB_USER', 'root');
define('DB_PASS', 'bpkdnotforsale');
define('DB_NAME', 'cms_instansi');
// Create connection
$conn = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Set charset
$conn->set_charset("utf8");
// Start session - PASTIKAN INI DIPANGGIL SETELAH TIDAK ADA OUTPUT
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
// Function to check login
function isLoggedIn() {
return isset($_SESSION['user_id']);
}
// Function to redirect - PERBAIKAN FUNGSI REDIRECT
function redirect($url) {
// Pastikan belum ada output sebelum redirect
if (!headers_sent()) {
header("Location: $url");
exit();
} else {
// Jika headers sudah terkirim, gunakan JavaScript
echo "<script>window.location.href='$url';</script>";
exit();
}
}
// Function to sanitize input
/*function sanitize($input) {
global $conn;
return mysqli_real_escape_string($conn, htmlspecialchars(trim($input)));
}
*/
?>