Commit f4f36df1 by Roy Junedi Simamora

Penambahan fungsi memesan

parent 424a1f0d
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
} }
elseif(isset($_SESSION['user'])){ elseif(isset($_SESSION['user'])){
echo' <li><a href="member_menu.php" ><span class="glyphicon glyphicon-th-list"></span>List Menu</a></li>'; echo' <li><a href="member_menu.php" ><span class="glyphicon glyphicon-th-list"></span>List Menu</a></li>';
$username = $_SESSION['username'];
} }
?> ?>
...@@ -44,7 +45,7 @@ ...@@ -44,7 +45,7 @@
<?php <?php
if(isset($_SESSION['user']) || isset($_SESSION['admin'])){ if(isset($_SESSION['user']) || isset($_SESSION['admin'])){
echo "<li><a href='form_login.php?logout'><span class='glyphicon glyphicon-log-out'></span> Logout</a></li>"; echo "<li><a href='form_login.php?logout'><span class='glyphicon glyphicon-log-out'></span>$username</a></li>";
} }
else { else {
echo '<li><a href="form_login.php"><span class="glyphicon glyphicon-log-in"></span>&nbsp;login</a></li>'; echo '<li><a href="form_login.php"><span class="glyphicon glyphicon-log-in"></span>&nbsp;login</a></li>';
......
...@@ -4,26 +4,49 @@ require 'koneksi.php'; ...@@ -4,26 +4,49 @@ require 'koneksi.php';
?> ?>
<br/> <br/>
<a class="btn btn-primary" href="member_menu.php"><span class="glyphicon glyphicon-chevron-left"></span> Kembali</a>
<hr/> <hr/>
<h3><span class="glyphicon glyphicon-eye-open"></span> Menu Detail </h3> <h3><span class="glyphicon glyphicon-eye-open"></span> Menu Detail </h3>
<div class="row"> <div class="row">
<?php <?php
$id = $_GET['id']; $id = $_GET['id'];
$id_user = $_GET['id_member'];
$query = mysqli_query($koneksi, "SELECT * FROM menu WHERE id_menu = '$id'");
while($q = mysqli_fetch_array($query)){
?> ?>
<div class="col-md-12"> <div class="col-md-6">
<div class="billInfo grid_11 alpha"> <div align="center">
<form method="post" action="pesan_proses.php?id=<?php echo $id; ?>" id="comment_form"> <img src="picture/<?php echo $q['gambar'] ?>" class="img img-thumbnail" width="300" height="300">
<fieldset> </div>
<label for="Jumlah">Jumlah: </label> </div>
<input type="text" tabindex="1" size="22" value="" name="jumlah" class="text" /> <div class="col-md-6">
<input type="submit" value="Pesan"/> <table class="table table-hover table-condensed">
<tr>
</fieldset> <td> Nama </td>
</form> <td> <?php echo $q['nama'] ?> </td>
</div> </tr>
</div> <tr>
</div> <td> Harga </td>
<td> Rp. <?php echo number_format($q['harga']) ?>,- </td>
</tr>
<tr>
<td>
<form action="pesan_proses.php?id=<?php echo $id?>" method="post">
<fieldset>
<label for="jumlah"> Jumlah </label>
<input type="text" tabindex="1" size="22" value="1" name="jumlah">&nbsp;
<input type="submit" value="Masukkan Ke Cart" class="btn btn-success">
</fieldset>
</form>
</td>
</tr>
</table>
<a class="btn btn-primary" href="member_menu.php"><span class="glyphicon glyphicon-chevron-left"></span>Pesan Lagi</a>
<a class="btn btn-warning" href="bayar.php?id=<?php echo $id ?>">Checkout<span class="glyphicon glyphicon-chevron-right"></span></a>
</div>
<?php
}
?>
</div>
<br/> <br/>
<?php <?php
......
...@@ -2,21 +2,27 @@ ...@@ -2,21 +2,27 @@
require_once(dirname(__FILE__).'/common/header.php'); require_once(dirname(__FILE__).'/common/header.php');
require_once(dirname(__FILE__).'/cek_login.php'); require_once(dirname(__FILE__).'/cek_login.php');
require_once(dirname(__FILE__).'/fungsi/session.php');
if(isset($_GET['do_login'])){ if(isset($_GET['do_login'])){
$login =getUser($_POST['username'],$_POST['password']); $login =getUser($_POST['username'],$_POST['password']);
if($login == false){ if($login == false){
$_SESSION['login_error'] = TRUE; $_SESSION['login_error'] = TRUE;
}else{ }else{
$_SESSION['user'] = TRUE;
$row = mysqli_fetch_assoc($login);
$_SESSION['username'] = $row['username'];
$_SESSION['id_member'] = $row['id_member'];
$_SESSION['user'] = TRUE; $_SESSION['user'] = TRUE;
$row = mysqli_fetch_assoc($resUsr);
$_SESSION['id_member'] = $row['id_member'];
header("location:index.php"); header("location:index.php");
} }
$log =getAdmin($_POST['username'],$_POST['password']); $log =getAdmin($_POST['username'],$_POST['password']);
if($log == false){ if($log == false){
$_SESSION['login_error'] = TRUE; $_SESSION['login_error'] = TRUE;
}else{ }else{
$resAdm = mysqli_fetch_array($log);
set_session('id', $resAdm['id_admin']);
set_session('nama', $resAdm['nama']);
$_SESSION['admin'] = TRUE; $_SESSION['admin'] = TRUE;
header("location:admin_menu.php"); header("location:admin_menu.php");
} }
......
...@@ -17,12 +17,15 @@ $start = ($page - 1) * $per_hal; ...@@ -17,12 +17,15 @@ $start = ($page - 1) * $per_hal;
?> ?>
<br/> <br/>
<?php <?php
if(isset($_SESSION['username'])){
$id_member = $_SESSION['id_member'];
}
$menu = mysqli_query($GLOBALS["___mysqli_ston"], "select * from menu limit $start, $per_hal"); $menu = mysqli_query($GLOBALS["___mysqli_ston"], "select * from menu limit $start, $per_hal");
while ($b = mysqli_fetch_array($menu)) { while ($b = mysqli_fetch_array($menu)) {
?> ?>
<div class="col-md-3"> <div class="col-md-3">
<a href="detail.php?id=<?php echo $b['id_menu'];?>" class="btn btn-lg btn-buy"> <a href="detail.php?id=<?php echo $b['id_menu'];?>&id_member=<?php echo $id_member; ?>" class="btn btn-lg btn-buy">
<img src="picture/<?php echo $b['gambar'] ?>" class="img-rounded" width="250" height="250"> <img src="picture/<?php echo $b['gambar'] ?>" class="img-rounded" width="250" height="250">
<div class="caption"> <div class="caption">
<h4 style="color: #3c3c3c;"> <?php echo $b['nama']; ?> </h4> <h4 style="color: #3c3c3c;"> <?php echo $b['nama']; ?> </h4>
......
<?php <?php
include 'koneksi.php'; session_start();
include 'fungsi/fungsi.php'; include 'koneksi.php';
include 'fungsi/session.php';
$id = $_GET['id']; $id = $_GET['id'];
$id_member = get_session('id'); $member_id = $_SESSION['id_member'];
$id_menu = $id; $menu_id = $id;
$tanggal = date('Y-m-d'); $tanggal = date('Y-m-d');
$jumlah = $_POST['jumlah']; $jumlah = $_POST['jumlah'];
mysqli_query($koneksi, "INSERT INTO pemesanan(member_id, menu_id, tanggal, jumlah,id_pemesanan) VALUES('$id_member','$id_menu','$tanggal','$jumlah','')");
mysqli_query($koneksi, "INSERT INTO pemesanan VALUES('', '$member_id', '$menu_id', '$tanggal', $jumlah)");
header('Location: detail.php?id='. $id .'&id_member='. $member_id);
?> ?>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment