Advertisement
hamjoricantiq

lib

Jan 14th, 2020
262
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.86 KB | None | 0 0
  1. <?php
  2.  
  3.     session_start();
  4.    
  5.     function base_url () {
  6.         return "http://localhost/pwpb_19/index.php";
  7.     }
  8.  
  9.     function flash($tipe, $pesan = '') {
  10.         if (empty($pesan)) {
  11.             $pesan = @$_SESSION[$tipe];
  12.             unset($_SESSION[$tipe]);
  13.             return $pesan;
  14.         }
  15.         else {
  16.             $_SESSION[$tipe] = $pesan;
  17.         }
  18.     }
  19.  
  20.     function cekLogin() {
  21.         $username = @$_SESSION['username'];
  22.         $level    = @$_SESSION['level'];
  23.  
  24.         if (empty($username) AND empty($level)) {
  25.             header("location: login.php");
  26.         }
  27.     }
  28.  
  29.     function sudahLogin() {
  30.         $username = @$_SESSION['username'];
  31.         $level    = @$_SESSION['level'];
  32.  
  33.         if (!empty($username) AND !empty($level)) {
  34.             header("location: index.php");
  35.         }  
  36.     }
  37.  
  38.     $host = 'localhost';
  39.     $user = 'root';
  40.     $pass = '';
  41.     $db = 'pwpb_19';
  42.    
  43.     $mysqli = mysqli_connect($host, $user, $pass, $db)
  44.             or die ('Tidak dapat koneksi ke Database');
  45. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement