LOADING . . .

Membuat Website Professional dengan PHP MySql - PART #4

1 Comment



Hi, sesuai dengan janji saya sebelumnya di posting Membuat Website Professional dengan PHP & MySql - PART #3 bahwa topik pada posting ini adalah men-design halaman admin/dashboard website professional anda. Langsung saja biar gak kepanjangan intro... 

Tapi sebelumnya saya ingin sampaikan bahwa saya tidak menjabarkan secara rinci bagaimana membuat template HTML dari awal/nol. Saya hanya akan mengkombinasikan website PHP yang kita buat dengan bantuan dari Template admin HTML Bootstrap, silahkan anda download terlebih dahulu disini. Oke, anda menemukan istilah baru yaitu bootstrap. Bootstrap merupakan sebuah library framework CSS yang telah dibuat khusus uintuk mengembangkan front end sebuah website. Bootstrap juga dikenal sebagai salah satu framework CSS, HTML, Javascript yang begitu populer di kalangan website developer atau pengembang website. Yang pasti bootstrap digunakan untuk mengembangkan website agar lebih responsive.

Yang perlu anda lakukan setelah men-download dan meng-ekstrak template HTML diatas adalah copy folder css, js, img, vendor, scss kedalam folder htdocs >> hospital >> admin, sehingga akan terlihat seperti gambar dibawah ini:

#1 Mengkombinasikan dan Membuat Login Admin

  1. Hidupkan XAMPP anda.
  2. Masuk ke dalam folder htdocs lalu folder hospital kemudian buka folder admin dan kemudian buka file index.php di text editor anda.
  3. Copy code berikut dan simpan 
    <!DOCTYPE html>
    <html lang="en">
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      <meta name="description" content="">
      <meta name="author" content="">
      
    <head>
    	<title>Suba Hospital | Admin</title>
        
        <!-- Custom fonts for this template-->
      <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
      <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
    
      <!-- Custom styles for this template-->
      <link href="css/sb-admin-2.min.css" rel="stylesheet">
    
    </head>
    <body class="bg-gradient-primary">
    	<div class="container">
    
        <!-- Outer Row -->
        <div class="row justify-content-center">
    
          <div class="col-xl-10 col-lg-12 col-md-9">
    
            <div class="card o-hidden border-0 shadow-lg my-5" style="width: 500px;margin: 0px auto;text-align: center;">
              <div class="card-body p-0">
                <!-- Nested Row within Card Body -->
                <div class="row">
                  
                  <div class="col-lg-12">
                    <div class="p-5">
                      <div class="text-center">
                        <h1 class="h4 text-gray-900 mb-4">Admin Login</h1>
                      </div>
                      <br/>
    	<!-- pesan -->
    	<?php 
    	if(isset($_GET['pesan'])){
    		if($_GET['pesan'] == "gagal"){
    			echo "Login gagal! username dan password salah!";
    		}else if($_GET['pesan'] == "logout"){
    			echo "Anda telah berhasil logout";
    		}else if($_GET['pesan'] == "belum_login"){
    			echo "Anda harus login untuk mengakses halaman dashboard";
    		}
    	}
    	?>
    	<br/>
    	<br/>
    	<form class="user" method="post" action="proses-login.php">
    		<div class="form-group">
                          <input type="text" class="form-control form-control-user" name="username" placeholder="Username" required>
                        </div>
                        <div class="form-group">
                          <input type="password" class="form-control form-control-user" id="exampleInputPassword" name="password" placeholder="Password" required>
                        </div>
    			<div class="form-group">
                          <button class="btn btn-primary btn-user btn-block">
                          Login
                        </button>
                        </div>
                        	
    	</form>
    <hr>
                      
                    </div>
                  </div>
                </div>
              </div>
            </div>
    
          </div>
    
        </div>
    
      </div>
    
      <!-- Bootstrap core JavaScript-->
      <script src="vendor/jquery/jquery.min.js"></script>
      <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    
      <!-- Core plugin JavaScript-->
      <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
    
      <!-- Custom scripts for all pages-->
      <script src="js/sb-admin-2.min.js"></script>
    
    </body>
    
    </html>​
  4.  Dari yang dilihat pada script diatas, kode yang sudah kita buat sebelumnya lihat di posting Membuat Website Professional dengan PHP & MySql - PART #3 bagian membuat Halaman Login tidaklah hilang, melainkan disisipkan di kode HTML bootstrap tadi. Lihat hasilnya pada browser apakah sudah seperti gambar dibawah? jika sudah, pastikan semua fungsi PHP berjalan dengan benar.

#2 Membuat Dashboard

  1. Masuk ke dalam folder htdocs lalu folder hospital kemudian buka folder admin dan kemudian buka file dashboard.php di text editor anda.
  2. Bagi menjadi beberapa bagian tujuannya untuk memudahkan anda melakukan perubahan pada halaman admin, jadi anda akan meminimalisir mengetik script HTML berkali-kali disetiap halaman, anda akan memanfaatkan fungsi "include" PHP (Lihat disini penjelasannya)
  3. Jadi anda akan buat file php baru yaitu topbar.php, sidebar.php dan footer.php
  4. Mari mulai dari topbar.php, copy kode berikut: 
            <nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
              <!-- Sidebar Toggle (Topbar) -->
              <button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
                <i class="fa fa-bars"></i>
              </button>
              <!-- Topbar Search -->
              <form class="d-none d-sm-inline-block form-inline mr-auto ml-md-3 my-2 my-md-0 mw-100 navbar-search">
                <div class="input-group">
                  <input type="text" class="form-control bg-light border-0 small" placeholder="Pencarian..." aria-label="Search" aria-describedby="basic-addon2">
                  <div class="input-group-append">
                    <button class="btn btn-primary" type="button">
                      <i class="fas fa-search fa-sm"></i>
                    </button>
                  </div>
                </div>
              </form>
              <!-- Topbar Navbar -->
              <ul class="navbar-nav ml-auto">
                <!-- Nav Item - Search Dropdown (Visible Only XS) -->
                <li class="nav-item dropdown no-arrow d-sm-none">
                  <a class="nav-link dropdown-toggle" href="#" id="searchDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <i class="fas fa-search fa-fw"></i>
                  </a>
                  <!-- Dropdown - Messages -->
                  <div class="dropdown-menu dropdown-menu-right p-3 shadow animated--grow-in" aria-labelledby="searchDropdown">
                    <form class="form-inline mr-auto w-100 navbar-search">
                      <div class="input-group">
                        <input type="text" class="form-control bg-light border-0 small" placeholder="Pencarian..." aria-label="Search" aria-describedby="basic-addon2">
                        <div class="input-group-append">
                          <button class="btn btn-primary" type="button">
                            <i class="fas fa-search fa-sm"></i>
                          </button>
                        </div>
                      </div>
                    </form>
                  </div>
                </li>
                <!-- Nav Webiste URL -->
                <li class="nav-item dropdown no-arrow mx-1">
                  <a  class="nav-link dropdown-toggle" style="color:black;" href="../index.php" target="_blank">Lihat Website</a>
                </li>
                <div class="topbar-divider d-none d-sm-block"></div>
                <!-- Nav Item - User Information -->
                <li class="nav-item dropdown no-arrow">
                  <a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <span class="mr-2 d-none d-lg-inline text-gray-600 small"><?php echo $_SESSION['username']; ?></span>
                    <img class="img-profile rounded-circle" src="https://source.unsplash.com/QAB-WJcbgJk/60x60">
                  </a>
                  <!-- Dropdown - User Information -->
                  <div class="dropdown-menu dropdown-menu-right shadow animated--grow-in" aria-labelledby="userDropdown">
                    <a class="dropdown-item" href="profile.php">
                      <i class="fas fa-user fa-sm fa-fw mr-2 text-gray-400"></i>
                      Profile
                    </a>
                    <a class="dropdown-item" href="profile-password.php">
                      <i class="fas fa-key fa-sm fa-fw mr-2 text-gray-400"></i>
                      Ubah Password
                    </a>
                  </div>
                </li>
              </ul>
            </nav>​
  5. sidebar.php, copy kode berikut: 
    <!-- Sidebar -->
        <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">
    
          <!-- Sidebar - Brand -->
          <a class="sidebar-brand d-flex align-items-center justify-content-center" href="dashboard.php">
            <div class="sidebar-brand-icon rotate-n-15">
              <i class="fas fa-hospital"></i>
            </div>
            <div class="sidebar-brand-text mx-3">Hospital</div>
          </a>
    
          <!-- Divider -->
          <hr class="sidebar-divider my-0">
    
          <!-- Nav Item - Dashboard -->
          <li class="nav-item active">
            <a class="nav-link" href="dashboard.php">
              <i class="fas fa-fw fa-tachometer-alt"></i>
              <span>Dashboard</span></a>
          </li>
    
          <!-- Divider -->
          <hr class="sidebar-divider">
    
          <!-- Heading -->
          <div class="sidebar-heading">
            Fitur Utama
          </div>
    
          <!-- Nav Item - Pages Collapse Menu -->
          <li class="nav-item">
            <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="true" aria-controls="collapseTwo">
              <i class="fas fa-fw fa-folder"></i>
              <span>Halaman</span>
            </a>
            <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionSidebar">
              <div class="bg-white py-2 collapse-inner rounded">
                <h6 class="collapse-header">Manajemen Halaman:</h6>
                <a class="collapse-item" href="halaman-list.php">List Halaman</a>
                <a class="collapse-item" href="halaman-tambah.php">Tambah Halaman</a>
              </div>
            </div>
          </li>
    
          <!-- Nav Item - Utilities Collapse Menu -->
          <li class="nav-item">
            <a class="nav-link collapsed" href="#" data-toggle="collapse" data-target="#collapseUtilities" aria-expanded="true" aria-controls="collapseUtilities">
              <i class="fas fa-file-alt"></i>
              <span>Post</span>
            </a>
            <div id="collapseUtilities" class="collapse" aria-labelledby="headingUtilities" data-parent="#accordionSidebar">
              <div class="bg-white py-2 collapse-inner rounded">
                <h6 class="collapse-header">Manajemen Post:</h6>
                <a class="collapse-item" href="post-list.php">List Post</a>
                <a class="collapse-item" href="post-tambah.php">Tambah Post</a>
                <a class="collapse-item" href="kategori-list.php">Kategori</a>
              </div>
            </div>
          </li>
    
          <!-- Divider -->
          <hr class="sidebar-divider">
    
        
    
          <!-- Nav Item - Tables -->
          <li class="nav-item">
            <a class="nav-link" href="logout.php">
              <i class="fas fa-arrow-right"></i>
              <span>Logout</span></a>
          </li>
    
          <!-- Divider -->
          <hr class="sidebar-divider d-none d-md-block">
    
          <!-- Sidebar Toggler (Sidebar) -->
          <div class="text-center d-none d-md-inline">
            <button class="rounded-circle border-0" id="sidebarToggle"></button>
          </div>
    
        </ul>
        <!-- End of Sidebar -->​
  6. footer.php, copy kode berikut: 
     <!-- Footer -->
          <footer class="sticky-footer bg-white">
            <div class="container my-auto">
              <div class="copyright text-center my-auto">
                <span>&copy; Aditya Subawa 2020</span>
              </div>
            </div>
          </footer>
          <!-- End of Footer -->​
  7. Dan tentunya dashboard.php tadi, copy kode berikut: 
    <?php 
    // menghubungkan dengan koneksi
    include "../config/koneksi.php";
    // mengaktifkan session php
    session_start();
    if($_SESSION['status'] !="login"){
    header("location:../");
    }
    ?>
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
    
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
      <meta name="description" content="">
      <meta name="author" content="">
    <head>
        <title>Suba Hospital | Dashboard</title>
        <!-- Custom fonts for this template-->
      <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
      <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
    
      <!-- Custom styles for this template-->
      <link href="css/sb-admin-2.min.css" rel="stylesheet">
    </head>
    <body id="page-top">
    
    <!-- Page Wrapper -->
      <div id="wrapper">
      	<?php include "sidebar.php"; ?>
        
        <!-- Content Wrapper -->
        <div id="content-wrapper" class="d-flex flex-column">
    
          <!-- Main Content -->
          <div id="content">
          
          <?php include "topbar.php";?>
          
          	<!-- Begin Page Content -->
            <div class="container-fluid">
            	<!-- Page Heading -->
              	<div class="d-sm-flex align-items-center justify-content-between mb-4">
                	<h1 class="h3 mb-0 text-gray-800">Dashboard</h1>
              	</div>
                
                <!-- Content Row -->
              <div class="row">
              <!-- Greeting -->
                <div class="col-lg-12">
    			<h4>Hi <?php echo $_SESSION['username']; ?>! anda telah login.</h4>
                </div>
              </div>
              <!-- End Content Row -->
              
            </div>
             <!-- End Page Content -->
          </div>
          <!-- End Content Wrapper -->
         <?php include "footer.php";?>
    
        </div>
        <!-- End Main Content -->
        </div>
        <!-- End Page Wrapper -->
         <!-- Bootstrap core JavaScript-->
      <script src="vendor/jquery/jquery.min.js"></script>
      <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
    
      <!-- Core plugin JavaScript-->
      <script src="vendor/jquery-easing/jquery.easing.min.js"></script>
    
      <!-- Custom scripts for all pages-->
      <script src="js/sb-admin-2.min.js"></script>
    
      <!-- Page level plugins -->
      <script src="vendor/chart.js/Chart.min.js"></script>
    
      <!-- Page level custom scripts -->
      <script src="js/demo/chart-area-demo.js"></script>
      <script src="js/demo/chart-pie-demo.js"></script>
    </body>
    </html>​
  8. Saya banyak melakukan modifikasi peletakan script PHP sesuai dengan kecocokan template HTML dari bootstrap. Lihat hasilnya di browser 

Anda bisa mendownload file tutorial posting ini disini. Stay Safe & Healthy. Selamat Hari Raya Nyepi...




I’d love to hear from you, leave a Reply!

  • Alif Nugroh March 26, 2020

    mantap bang, aku tunggu lanjutannya