1. Bagian Admin
form login ( menggunakan session )
<?php session_start();
error_reporting(0);
if(isset($_SESSION['id_admin'])){
?>
<script language="javascript">document.location.href='dashboard.php'</script>
<?php
}
else if(isset($_SESSION['id_kasir'])){
?>
<script language="javascript">document.location.href='kasir/dashboard.php'</script>
<?php
}
else{
?>
<!DOCTYPE html>
<html>
<head>
<title>Login Kasir</title>
</head>
<body>
<?php
error_reporting(0);
$status=$_GET['status'];
$loginas=$_GET['loginas'];
?>
<center>
<h1>Form Login</h1><br>
<h2><?php echo $status;?></h2>
<br>
<form method="POST" action="login_action.php">
<table>
<tr>
<td>Login Sebagai</td>
<?php if($loginas=='kasir'){?>
<td>
<select name="loginas">
<option value="admin">Admin</option>
<option value="kasir" selected="true">Kasir</option>
</select>
</td>
<?php }
else{ ?>
<td>
<select name="loginas">
<option value="admin">Admin</option>
<option value="kasir">Kasir</option>
</select>
</td>
<?php } ?>
</tr>
<tr>
<td>ID</td>
<td><input type="text" name="id"></td>
</tr>
<tr>
<td>Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td colspan="1"><button type="submit">Log in</button></td>
</tr>
</table>
</form>
</center>
</body>
</html>
<?php
}?>
halaman dashboard
<?php session_start();
if(isset($_SESSION['id_admin'])){
?>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- bootstrap.css CDN -->
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/bootstrap.css" rel="stylesheet" />
<link href="css/dashboard.css" rel="stylesheet" />
</head>
<body>
<?php $admin=ucwords($_SESSION['nama']);?>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><span class="glyphicon glyphicon-home"></span>
Dashboard Admin</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Bantuan</a></li>
<li>
<a href="logout_action.php" onClick="return confirm(' <?php echo $admin;?>, Apakah Anda yakin akan keluar?')">Logout</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li class="active"><a href="dashboard.php">Beranda <span class="sr-only">(current)</span></a></li>
</ul>
<ul class="nav nav-sidebar">
<li><a href="input.php">Input Menu</a></li>
<li><a href="kelola.php">Kelola Menu</a></li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<h1 class="page-header">Beranda</h1>
<h3>Assalamualaikum... <?php
echo $admin;
?></h3>
<p> Selamat datang di dashboard aplikasi Kasir Restaurant, semoga aplikasi ini membantu kelancaran bisnis kuliner anda. Terimakasih</p>
<br>"Jika terjadi error dalam aplikasi ini, harap hubungi kami" (Pengembang)</font>
<br>
</div>
</div>
</div>
</div>
<!-- /container -->
<!-- ===================
SCRIPTS
======================== -->
<!-- jQuery.js CDN -->
<script src="js/jquery.min.js"></script>
<!-- bootstrap.js CDN -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<?php
}else{
?><script language="javascript">document.location.href='index.php?status=Anda belum login!'</script><?php
}
?>
form input
<?php session_start();
if(isset($_SESSION['id_admin'])){ => masuk sebagai admin
?>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- bootstrap.css CDN -->
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/bootstrap.css" rel="stylesheet" />
<link href="css/dashboard.css" rel="stylesheet" />
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><span class="glyphicon glyphicon-home"></span>
Dashboard Admin</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Bantuan</a></li>
<li>
<a href="logout_action.php" onClick="return confirm('Apakah Anda yakin akan keluar?')">Logout</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li ><a href="dashboard.php">Beranda <span class="sr-only">(current)</span></a></li>
</ul>
<ul class="nav nav-sidebar">
<li class="active"><a href="input.php">Input Menu</a></li>
<li><a href="kelola.php">Kelola Menu</a></li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<h1 class="page-header">Input Menu</h1>
<h3>Input Menu Makan/ Minuman</h3> =>form input
<form role="form" method="post" action="prosesinput.php" id="forminput">
<table width="400">
<tr>
<td>Kode Menu</td>
<td><input type="text" name="kdmenu" placeholder="Kode Menu" required id="kdmenu" onchange="validasi()" > </td> => validasi form kode menu harus diisi dan harus angka
</tr>
<tr>
<td>Nama Menu</td>
<td><input type="text" name="nama_menu" placeholder="Nama Menu" required="true" > </td> => validasi form nama menu harus diisi
</tr>
<tr>
<td>Jenis</td>
<td>
<select name="jenis" width="50px">
<option value="Makanan">Makanan</option>
<option value="Minuman">Minuman</option>
<option value="Snack">Snack</option>
</select>
</td>
</tr>
<tr>
<td>Harga</td>
<td> <input type="text" name="harga" placeholder="Harga" required="true"> </td>
</tr> => validasi form harga harus diisi
</table>
<input type="submit" value="Submit" >
</form>
<script type="text/javascript">
function validasi(){ => validasi kode menu harus angka
var kdmenu= document.forms["forminput"]["kdmenu"].value;
var number=/^[0-9]+$/;
if(kdmenu.length <3)
alert("kode harus lebih dr 3");
else if (!kdmenu.match(number))
alert("Harus Angka");
return false;
};
}
</script>
</div>
</div>
</div>
</div>
<!-- /container -->
<!-- ===================
SCRIPTS
======================== -->
<!-- jQuery.js CDN -->
<script src="js/jquery.min.js"></script>
<!-- bootstrap.js CDN -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<?php
}else{
?><script language="javascript">document.location.href='index.php?status=Anda belum login!'</script><?php
}
?>
proses input
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<?php
$host = "localhost";
$username= "root";
$password ="";
$database="rest";
$konek = new mysqli($host, $username, $password, $database);
if($konek->connect_error){
die("errornya adalah : ".$konek->connect_error);
}
$kodemenu =$_POST["kdmenu"];
$namamenu =$_POST["nama_menu"];
$jenis =$_POST["jenis"];
$harga =$_POST["harga"];
$sql =mysqli_query($konek, "INSERT INTO menu values('$kodemenu','$namamenu','$jenis','$harga')");
if($sql){
echo "INPUT DATA BERHASIL";
}
else{
echo "INPUT DATA";
}
?>
</script>
<a href="input.php"><button>Kembali</button></a>
</body>
</html>
tampilan form input
<?php session_start();
if(isset($_SESSION['id_admin'])){
?>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- bootstrap.css CDN -->
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/bootstrap.css" rel="stylesheet" />
<link href="css/dashboard.css" rel="stylesheet" />
</head>
<body>
<?php $admin=ucwords($_SESSION['nama']);
?>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><span class="glyphicon glyphicon-home"></span>
Dashboard Admin</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Bantuan</a></li>
<li>
<a href="logout_action.php" onClick="return confirm(' <?php echo $admin;?>, Apakah Anda yakin akan keluar?')">Logout</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li><a href="dashboard.php">Beranda <span class="sr-only">(current)</span></a></li>
</ul>
<ul class="nav nav-sidebar">
<li><a href="input.php">Input Menu</a></li>
<li class="active"><a href="kelola.php">Kelola Menu</a></li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<h1 class="page-header">Kelola Menu</h1>
<center>
<h3>Daftar Menu</h3>
<table width="80%" border="1">
<tr>
<td align="center" width="25px">No</td>
<td align="center">Id</td>
<td align="center">Nama</td>
<td align="center">Harga</td>
<td align="center">Aksi</td>
</tr>
<?php
$host ="localhost";
$username ="root";
$password ="";
$database ="rest";
$konek = new mysqli($host, $username, $password, $database);
if($konek->connect_error){
die("errornya adalah : ".$konek->connect_error);
}
$sql =mysqli_query($konek, "select*from menu order by kdmenu ASC");
$i=1;
?>
<?php while($row=$sql->fetch_array()){ ?>
<tr>
<td align="center"><?php echo $i; ?></td>
<td align="center"><?php echo $row["kdmenu"]; ?></td>
<td><?php echo $row["nama_menu"]; ?></td>
<td><?php echo "Rp. ".$row["harga"]; ?></td>
<td align="center">
<a href="editmenu.php?kdmenu=<?php echo $row['kdmenu']; ?>&nama_menu=<?php echo $row['nama_menu'];?>&jenis=<?php echo $row['jenis'];?>&harga=<?php echo $row['harga']; ?>"><button>Edit</button></a>
<a href="proseshapus.php?kdmenu=<?php echo $row['kdmenu']; ?>"><button>Hapus</button></a>
</td>
</tr>
<?php $i++;} ?>
</table>
</center>
</div>
</div>
</div>
</div>
<!-- /container -->
<!-- ===================
SCRIPTS
======================== -->
<!-- jQuery.js CDN -->
<script src="js/jquery.min.js"></script>
<!-- bootstrap.js CDN -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<?php
}else{
?><script language="javascript">document.location.href='index.php?status=Anda belum login!'</script><?php
}
?>
proses hapus
<?php
$host = "localhost";
$username= "root";
$password ="";
$database="rest";
$konek = new mysqli($host, $username, $password, $database);
$kdmenu=$_GET['kdmenu'];
$query="DELETE FROM menu WHERE kdmenu = $kdmenu";
mysqli_query($konek,$query);
echo "Hapus Berhasil";?>
<script language=javascript>
setTimeout("location.href='kelola.php'",1000);
</script>
tampilan kelola menu
form untuk edit menu
<?php session_start();
if(isset($_SESSION['id_admin'])){
?>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<!-- bootstrap.css CDN -->
<link href="css/bootstrap.min.css" rel="stylesheet" />
<link href="css/bootstrap.css" rel="stylesheet" />
<link href="css/dashboard.css" rel="stylesheet" />
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#"><span class="glyphicon glyphicon-home"></span>
Dashboard Admin</a>
</div>
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Bantuan</a></li>
<li>
<a href="#" onClick="return alert('Anda harus menyelesaikan proses edit!')">Logout</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<li class="disabled"><a href="dashboard.php">Beranda <span class="sr-only">(current)</span></a></li>
</ul>
<ul class="nav nav-sidebar">
<li class="disabled"><a href="input.php">Input Menu</a></li>
<li class="active"><a href="#">Edit Menu</a></li>
</ul>
</div>
<div class="col-sm-9 col-sm-offset-3 col-md-10 col-md-offset-2 main">
<h1 class="page-header">Edit Menu</h1>
<?php
$kdmenu =$_GET['kdmenu'];
$nama_menu =$_GET['nama_menu'];
$jenis=$_GET['jenis'];
$harga=$_GET['harga'];
?>
<form role="form" method="post" action="prosesedit.php" id="forminput">
<table width="400">
<tr>
<td>Kode Menu</td>
<td><input type="text" name="kdmenu" value="<?php echo $kdmenu; ?>" disabled="true">
<input type="hidden" name="kdmenu" value="<?php echo $kdmenu;?>">
</td>
</tr>
<tr>
<td>Nama Menu</td>
<td><input type="text" name="nama_menu" placeholder="Nama Menu" required="true" value="<?php echo $nama_menu?>"> </td>
</tr>
<tr>
<td>Jenis</td>
<td>
<!--UNTUK MENETUKAN JENIS YANG DIPILIH-->
<select name="jenis" width="50px">
<?php if($jenis=='Makanan'){?>
<option value="Makanan" selected="true">Makanan</option>
<option value="Minuman">Minuman</option>
<option value="Snack">Snack</option>
<?php }
elseif($jenis=='Minuman'){?>
<option value="Makanan">Makanan</option>
<option value="Minuman" selected="true">Minuman</option>
<option value="Snack">Snack</option>
<?php }
else{?>
<option value="Makanan">Makanan</option>
<option value="Minuman">Minuman</option>
<option value="Snack" selected="true">Snack</option>
<?php } ?>
</select>
</td>
</tr>
<tr>
<td>Harga</td>
<td> <input type="text" name="harga" placeholder="Harga" required="true" value="<?php echo $harga; ?>"> </td>
</tr>
</table>
<input type="submit" value="Update" >
</form>
<script type="text/javascript">
function validasi(){
var kdmenu= document.forms["forminput"]["kdmenu"].value;
var number=/^[0-9]+$/;
if (!kdmenu.match(number)) {
alert("Harus Angka");
return false;
};
}
</script>
</div>
</div>
</div>
</div>
<!-- /container -->
<!-- ===================
SCRIPTS
======================== -->
<!-- jQuery.js CDN -->
<script src="js/jquery.min.js"></script>
<!-- bootstrap.js CDN -->
<script src="js/bootstrap.min.js"></script>
</body>
</html>
<?php
}else{
?><script language="javascript">document.location.href='index.php?status=Anda belum login!'</script><?php
}
?>
proses edit
<?php
$host = "localhost";
$username= "root";
$password ="";
$database="rest";
$konek = new mysqli($host, $username, $password, $database);
$kdmenu=$_POST['kdmenu'];
$nama_menu=$_POST['nama_menu'];
$jenis=$_POST['jenis'];
$harga=$_POST['harga'];
$query="UPDATE menu set nama_menu = '$nama_menu', jenis='$jenis',harga='$harga' where kdmenu='$kdmenu'";
mysqli_query($konek,$query);
echo "Edit Berhasil";?>
<script language=javascript>
setTimeout("location.href='kelola.php'",1000);
</script>
tampilan edit menu