Tugas Sesi 3 LSP
Tugas Sesi 3 LSP
Tugas Sesi 3 LSP
Button Login Admin diletakkan pada bagian footer landing page, dan ketika button tersebut akan
langsung terdirect ke halaman login. Setelah login maka akan masuk kedalam halaman login.php,
lalu setelah login akan masuk ke dalam halaman admin panel
2. Codingan halaman login
<?php
session_start();
$connection = mysqli_connect('localhost', 'root', '', 'madingonline') or
die ('koneksi db tidak terhubung!')
?>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css" />
<link
href="https://fonts.googleapis.com/css2?family=Lato:wght@300;400;700&famil
y=Roboto:wght@400;500;900&display=swap" rel="stylesheet">
<title>Admin Login</title>
</head>
<body>
<div class="login-form">
<form action="login.php" method="post" class="loginlogin-form">
<h1 class="loginh1">Admin Mading Online</h1>
<div class="formInput">
<label class="lblform">Username</label>
<input type="text" name="username" placeholder="Username"
required="" class="input-form"
/>
<span class="span-form"></span>
</div>
<div class="formInput">
<label class="lblform">Password</label>
<input type="password" name="password" placeholder="Password"
required="" class="input-form"
/>
<span class="span-form"></span>
</div>
<button type="submit" name="login" value="Login" class="btn-
login">Submit</button>
</form>
</div>
<?php
if (isset($_POST['login'])){
$username = $_POST['username'];
$password = $_POST['password'];
if(is_array($row)) {
$_SESSION["username"] = $row['username'];
$_SESSION["password"] = $row['password'];
} else {
echo '<script type = "text/javascript">';
echo 'alert("username atau password salah!");';
echo 'window.location.href = "login.php" ';
echo '</script>';
}
}
if(isset($_SESSION["username"])){
header("Location:dashboard.php");
}
?>
</body>
</html>
3. Codingan halaman admin
Pada bagian halaman admin saya menggunakan framework dari niceadmin dan saya
implementasikan ke dalam codingan saya dengan nama file Dashboard.php.
<?php
session_start();
if (!isset($_SESSION['username'])) {
header("Location: login.php");
}
?>
<a href="logout.php">logout</a>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1.0" name="viewport">
<!-- =======================================================
* Template Name: NiceAdmin
* Updated: May 30 2023 with Bootstrap v5.3.0
* Template URL: https://bootstrapmade.com/nice-admin-bootstrap-admin-
html-template/
* Author: BootstrapMade.com
* License: https://bootstrapmade.com/license/
======================================================== -->
</head>
<body>
<div class="search-bar">
<form class="search-form d-flex align-items-center" method="POST"
action="#">
<input type="text" name="query" placeholder="Search" title="Enter
search keyword">
<button type="submit" title="Search"><i class="bi bi-
search"></i></button>
</form>
</div><!-- End Search Bar -->
<li class="notification-item">
<i class="bi bi-exclamation-circle text-warning"></i>
<div>
<h4>Lorem Ipsum</h4>
<p>Quae dolorem earum veritatis oditseno</p>
<p>30 min. ago</p>
</div>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li class="notification-item">
<i class="bi bi-x-circle text-danger"></i>
<div>
<h4>Atque rerum nesciunt</h4>
<p>Quae dolorem earum veritatis oditseno</p>
<p>1 hr. ago</p>
</div>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li class="notification-item">
<i class="bi bi-check-circle text-success"></i>
<div>
<h4>Sit rerum fuga</h4>
<p>Quae dolorem earum veritatis oditseno</p>
<p>2 hrs. ago</p>
</div>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li class="notification-item">
<i class="bi bi-info-circle text-primary"></i>
<div>
<h4>Dicta reprehenderit</h4>
<p>Quae dolorem earum veritatis oditseno</p>
<p>4 hrs. ago</p>
</div>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li class="dropdown-footer">
<a href="#">Show all notifications</a>
</li>
<li class="message-item">
<a href="#">
<img src="assets/img/messages-1.jpg" alt=""
class="rounded-circle">
<div>
<h4>Maria Hudson</h4>
<p>Velit asperiores et ducimus soluta repudiandae labore
officia est ut...</p>
<p>4 hrs. ago</p>
</div>
</a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li class="message-item">
<a href="#">
<img src="assets/img/messages-2.jpg" alt=""
class="rounded-circle">
<div>
<h4>Anna Nelson</h4>
<p>Velit asperiores et ducimus soluta repudiandae labore
officia est ut...</p>
<p>6 hrs. ago</p>
</div>
</a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li class="message-item">
<a href="#">
<img src="assets/img/messages-3.jpg" alt=""
class="rounded-circle">
<div>
<h4>David Muldon</h4>
<p>Velit asperiores et ducimus soluta repudiandae labore
officia est ut...</p>
<p>8 hrs. ago</p>
</div>
</a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li class="dropdown-footer">
<a href="#">Show all messages</a>
</li>
<li>
<a class="dropdown-item d-flex align-items-center"
href="users-profile.html">
<i class="bi bi-person"></i>
<span>My Profile</span>
</a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li>
<a class="dropdown-item d-flex align-items-center"
href="users-profile.html">
<i class="bi bi-gear"></i>
<span>Account Settings</span>
</a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li>
<a class="dropdown-item d-flex align-items-center"
href="pages-faq.html">
<i class="bi bi-question-circle"></i>
<span>Need Help?</span>
</a>
</li>
<li>
<hr class="dropdown-divider">
</li>
<li>
<a class="dropdown-item d-flex align-items-center" href="#">
<i class="bi bi-box-arrow-right"></i>
<span>
<a href="logout.php">Sign Out</a>
</span>
</a>
</li>
</ul>
</nav><!-- End Icons Navigation -->
<li class="nav-item">
<a class="nav-link collapsed" href="index.html">
<i class="bi bi-grid"></i>
<span>Dashboard</span>
</a>
</li><!-- End Dashboard Nav -->
<li class="nav-item">
<a class="nav-link collapsed" data-bs-target="#components-nav"
data-bs-toggle="collapse" href="#">
<i class="bi bi-menu-button-wide"></i><span>Components</span><i
class="bi bi-chevron-down ms-auto"></i>
</a>
<ul id="components-nav" class="nav-content collapse " data-bs-
parent="#sidebar-nav">
<li>
<a href="components-alerts.html">
<i class="bi bi-circle"></i><span>Alerts</span>
</a>
</li>
<li>
<a href="components-accordion.html">
<i class="bi bi-circle"></i><span>Accordion</span>
</a>
</li>
<li>
<a href="components-badges.html">
<i class="bi bi-circle"></i><span>Badges</span>
</a>
</li>
<li>
<a href="components-breadcrumbs.html">
<i class="bi bi-circle"></i><span>Breadcrumbs</span>
</a>
</li>
<li>
<a href="components-buttons.html">
<i class="bi bi-circle"></i><span>Buttons</span>
</a>
</li>
<li>
<a href="components-cards.html">
<i class="bi bi-circle"></i><span>Cards</span>
</a>
</li>
<li>
<a href="components-carousel.html">
<i class="bi bi-circle"></i><span>Carousel</span>
</a>
</li>
<li>
<a href="components-list-group.html">
<i class="bi bi-circle"></i><span>List group</span>
</a>
</li>
<li>
<a href="components-modal.html">
<i class="bi bi-circle"></i><span>Modal</span>
</a>
</li>
<li>
<a href="components-tabs.html">
<i class="bi bi-circle"></i><span>Tabs</span>
</a>
</li>
<li>
<a href="components-pagination.html">
<i class="bi bi-circle"></i><span>Pagination</span>
</a>
</li>
<li>
<a href="components-progress.html">
<i class="bi bi-circle"></i><span>Progress</span>
</a>
</li>
<li>
<a href="components-spinners.html">
<i class="bi bi-circle"></i><span>Spinners</span>
</a>
</li>
<li>
<a href="components-tooltips.html">
<i class="bi bi-circle"></i><span>Tooltips</span>
</a>
</li>
</ul>
</li><!-- End Components Nav -->
<li class="nav-item">
<a class="nav-link collapsed" data-bs-target="#forms-nav" data-bs-
toggle="collapse" href="#">
<i class="bi bi-journal-text"></i><span>Forms</span><i class="bi
bi-chevron-down ms-auto"></i>
</a>
<ul id="forms-nav" class="nav-content collapse " data-bs-
parent="#sidebar-nav">
<li>
<a href="forms-elements.html">
<i class="bi bi-circle"></i><span>Form Elements</span>
</a>
</li>
<li>
<a href="forms-layouts.html">
<i class="bi bi-circle"></i><span>Form Layouts</span>
</a>
</li>
<li>
<a href="forms-editors.html">
<i class="bi bi-circle"></i><span>Form Editors</span>
</a>
</li>
<li>
<a href="forms-validation.html">
<i class="bi bi-circle"></i><span>Form Validation</span>
</a>
</li>
</ul>
</li><!-- End Forms Nav -->
<li class="nav-item">
<a class="nav-link collapsed" data-bs-target="#tables-nav" data-
bs-toggle="collapse" href="#">
<i class="bi bi-layout-text-window-
reverse"></i><span>Tables</span><i class="bi bi-chevron-down ms-auto"></i>
</a>
<ul id="tables-nav" class="nav-content collapse " data-bs-
parent="#sidebar-nav">
<li>
<a href="tables-general.html">
<i class="bi bi-circle"></i><span>General Tables</span>
</a>
</li>
<li>
<a href="tables-data.html">
<i class="bi bi-circle"></i><span>Data Tables</span>
</a>
</li>
</ul>
</li><!-- End Tables Nav -->
<li class="nav-item">
<a class="nav-link collapsed" data-bs-target="#charts-nav" data-
bs-toggle="collapse" href="#">
<i class="bi bi-bar-chart"></i><span>Charts</span><i class="bi
bi-chevron-down ms-auto"></i>
</a>
<ul id="charts-nav" class="nav-content collapse " data-bs-
parent="#sidebar-nav">
<li>
<a href="charts-chartjs.html">
<i class="bi bi-circle"></i><span>Chart.js</span>
</a>
</li>
<li>
<a href="charts-apexcharts.html">
<i class="bi bi-circle"></i><span>ApexCharts</span>
</a>
</li>
<li>
<a href="charts-echarts.html">
<i class="bi bi-circle"></i><span>ECharts</span>
</a>
</li>
</ul>
</li><!-- End Charts Nav -->
<li class="nav-item">
<a class="nav-link collapsed" data-bs-target="#icons-nav" data-bs-
toggle="collapse" href="#">
<i class="bi bi-gem"></i><span>Icons</span><i class="bi bi-
chevron-down ms-auto"></i>
</a>
<ul id="icons-nav" class="nav-content collapse " data-bs-
parent="#sidebar-nav">
<li>
<a href="icons-bootstrap.html">
<i class="bi bi-circle"></i><span>Bootstrap Icons</span>
</a>
</li>
<li>
<a href="icons-remix.html">
<i class="bi bi-circle"></i><span>Remix Icons</span>
</a>
</li>
<li>
<a href="icons-boxicons.html">
<i class="bi bi-circle"></i><span>Boxicons</span>
</a>
</li>
</ul>
</li><!-- End Icons Nav -->
<li class="nav-heading">Pages</li>
<li class="nav-item">
<a class="nav-link collapsed" href="users-profile.html">
<i class="bi bi-person"></i>
<span>Profile</span>
</a>
</li><!-- End Profile Page Nav -->
<li class="nav-item">
<a class="nav-link collapsed" href="pages-faq.html">
<i class="bi bi-question-circle"></i>
<span>F.A.Q</span>
</a>
</li><!-- End F.A.Q Page Nav -->
<li class="nav-item">
<a class="nav-link collapsed" href="pages-contact.html">
<i class="bi bi-envelope"></i>
<span>Contact</span>
</a>
</li><!-- End Contact Page Nav -->
<li class="nav-item">
<a class="nav-link collapsed" href="pages-register.html">
<i class="bi bi-card-list"></i>
<span>Register</span>
</a>
</li><!-- End Register Page Nav -->
<li class="nav-item">
<a class="nav-link collapsed" href="pages-login.html">
<i class="bi bi-box-arrow-in-right"></i>
<span>Login</span>
</a>
</li><!-- End Login Page Nav -->
</ul>
<div class="pagetitle">
<h1>Blank Page</h1>
<nav>
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="index.html">Home</a></li>
<li class="breadcrumb-item">Pages</li>
<li class="breadcrumb-item active">Blank</li>
</ol>
</nav>
</div><!-- End Page Title -->
<section class="section">
<div class="row">
<div class="col-lg-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Example Card</h5>
<p>This is an examle page with no contrnt. You can use it as
a starter for your custom pages.</p>
</div>
</div>
</div>
<div class="col-lg-6">
<div class="card">
<div class="card-body">
<h5 class="card-title">Example Card</h5>
<p>This is an examle page with no contrnt. You can use it as
a starter for your custom pages.</p>
</div>
</div>
</div>
</div>
</section>
</body>
</html>