hi i need some help here. i need to make a checkout page for online event ticket
ID: 3842176 • Letter: H
Question
hi i need some help here. i need to make a checkout page for online event ticket booking . the page where usually it will display to you info like "transaction is successful" with name, student ID, name of the event, price and total amount the user already paid .
below are my coding and hope u can fix it up. my job is only to call back the data from database that the user has input from previous page.
and please explain my mistakes
<!DOCTYPE>
<?php
session_start();
include ("functions/function.php");
?>
<html>
<html lang="en">
<head>
<title>Event List</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
<head>
<title> UEET </title>
<style>
<style>
/* Remove the navbar's default margin-bottom and rounded borders */
.body{
background: cover;
}
.navbar {
margin-bottom: 0;
border-radius: 0;
}
/* Set black background color, white text and some padding */
header {
background-color: #020202;
font-family:Times New Roman;
font-size: 30px;
color: white;
padding: 6px;
}
footer {
background-color: #020202;
font-family:Times New Roman;
color: white;
padding: 15px;
}
/* On small screens, set height to 'auto' for sidenav and grid */
@media screen and (max-width: 767px) {
.sidenav {
height: auto;
padding: 15px;
}
</style>
<link rel="stylesheet" href="styles/style.css" media="all" />
</head>
</style>
</head>
<body>
</html>
<header class="container-fluid text-center">
<marquee behavior="alternate" direction="up" width="80%">
<marquee direction="right" behavior="alternate">
<h1>UMP EVENT E-TICKETING</h1></marquee>
</marquee>
</header>
<nav class="navbar navbar-inverse">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href=""><img src=""></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="AddEvent.php">Add Event</a></li>
<li class="active"><a href="EventList.php">Event List</a></li>
<li><a href="#">Update Event</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="login.php"><span class="glyphicon glyphicon-log-in"></span> Logout</a></li>
</ul>
</div>
</div>
</nav>
<div class="container-fluid text-center">
<div class="col-sm-8 text-left">
<caption><h1>Event List</h1></caption>
<body>
<div class="main_wrapper">
<div class="header_wrapper">
<img id="logo" src="images/logocafe.png" height="100" width="200"/>
</div>
<div class="menubar">
<ul id="menu">
<li><a href="home.php">Home</a></li>
<li><a href="Updateevent.php">All Product</a></li>
<li><a href="customers/my_account">My Account</a></li>
<li><a href="registration.php">Sign Up</a></li>
<li><a href="payment.php">payment</a></li>
<li><a href="#">Contact Us</a></li>
</ul>
<div id="form">
<form method ="get" action="results.php" enctype="multipart/form-data">
<input type="text" name="user_query" placeholder="Search a Food"/>
<input type="submit" name="search" value="Search" />
</form>
</div>
</div>
<div class="content_wrapper">
<div id="sidebar">
<div id="sidebar_title">Cafes</div>
<ul id="cats">
<?php getCats(); ?>
</ul>
</div>
<div id="content_area">
<?php cart(); ?>
<div id="shopping_cart">
<span>
<?php
if(isset($_SESSION['customer_email'])){
echo "<b>Welcome: </b>" . $_SESSION['matrixID'] . "<b>Your</b>";
}
else{
echo "<b>Welcome Guest</b>";
}
?>
<b>Shopping Cart - </b>Total event : <?php total_items();?> Total Price: <?php total_price(); ?> <a href="index.php">Back to Shop</a>
<?php
if(!isset($_SESSION['customer_email'])){
echo"<a href="checkout.php">Login</a>";
}
else{
echo"<a href="logout.php">Logout</a>";
}
?>
</span>
</div>
<div id="products_box">
<br>
<form action="" method="post" enctype="multipart/form-data">
<table align="center" width = "700" bgcolor="skyblue">
<tr align = "center">
</tr>
<tr align="center">
<th>Remove</th>
<th>Product(s)</th>
<th>Quantity</th>
<th>Total Price</th>
</tr>
<?php
$total = 0;
global $con;
$ip = getIp();
$sel_price = "select * from cart where ip_add='$ip'";
$run_price = mysqli_query($con, $sel_price);
while($p_price = mysqli_fetch_array($run_price)){
$pro_id = $p_price['p_id'];
$pro_price = "select * from products where product_id = '$pro_id'";
$run_pro_price = mysqli_query($con, $pro_price);
while ($pp_price = mysqli_fetch_array($run_pro_price)){
$product_price = array($pp_price['product_price']);
$product_title = $pp_price['product_title'];
$product_image = $pp_price ['product_image'];
$single_price= $pp_price['product_price'];
$values = array_sum($product_price);
$total +=$values;
?>
<tr align="center">
<td><input type = "checkbox" name="remove[]" value="<?php echo $pro_id;?>"/></td>
<td><?php echo $product_title; ?><br>
<img src="adminarea/product_images/<?php echo $product_image;?>" width="60" height="60"/>
</td>
<td><input type="text" size = "4" name="qty" value="<?php echo $_SESSION['qty'];?>"/></td>
<?php
if(isset($_POST['update_cart'])){
$qty = $_POST['qty'];
$update_qty = "update cart set qty='$qty'";
$run_qty = mysql_query($con, $update_qty);
$_SESSION ['qty']=$qty;
$total = $total*$qty;
}
?>
<td><?php echo "RM" . $single_price;?></td>
</tr>
<?php }}?>
<tr align="right">
<td colspan="4"><b> Sub Total:</b></td>
<td><?php echo "RM". $total;?></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" name ="update_cart" value="Update Cart" /></td>
<td><input type="submit" name="continue" value="Continue Shopping" /></td>
<td><button><a href="checkout.php">Checkout</a></button></a></td>
</tr>
</table>
</form>
<?php
function updatecart(){
global $con;
$ip = getIp();
if (isset($_POST['update_cart'])){
foreach($_POST['remove'] as $remove_id){
$delete_product = "delete from cart where p_id='$remove_id' AND ip_add='$ip'";
$run_delete = mysqli_query($con, $delete_product);
if($run_delete){
echo "<script>window.open('cart.php','_self')</script>";
}
}
}
if(isset($_POST['continue'])){
$valueToSearch = $_POST['valueToSearch'];
query = "SELECT * FROM `event` WHERE CONCAT(`id`, `name`, `date`, `place`, `description`, `ticket`) LIKE '%".$valueToSearch."%'";
$search_result = filterTable($query);
}
else {
$query = "SELECT * FROM `event`";
$search_result = filterTable($query);
echo "<script>window.open('index.php','_self')</script>";
function filterTable($query)
{
$connect = mysqli_connect("localhost", "root", "", "webscriptproject");
$filter_Result = mysqli_query($connect, $query);
return $filter_Result;
}
echo @$up_cart = updatecart();
}
?>
</div>
</div>
</div>
<div id="footer">
<h2>© 2016 by food2ump.my </h2>
</div>
<form action="EventList.php" method="post">
<input type="text" name="valueToSearch" placeholder="Value To Search">
<br> <br>
<?php while($row = mysqli_fetch_array($search_result)):
$id = $row["id"];?>
<ul>
<li>
student name : <?php echo $row['username'] ; ?><br>
student ID: <?php echo $row['matricID'] ; ?><br>
Event Name : <?php echo $row['name']; ?><br>
Date : <?php echo $row['date']; ?><br>
Place : <?php echo $row['place']; ?><br>
Description : <?php $row['description']; ?><br>
Ticket : RM <?php echo $row['ticket']; ?>
<input type="button" value="Update" />
<input type="button" value="Delete" />
<br>
<hr>
</li>
</ul>
<?php
endwhile;
?>
</form>
<div class="col-sm-2 sidenav">
</div>
</div>
</div>
</div>
</body>
</html>
Explanation / Answer
Hey there, there is considerable amount of code in functions.php that I really need to work with this problem, please post that code too as an edit as soon as possible.
Cheers,
Primehero
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.