%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /proc/self/root/home/eirtvhdf/public_html/
Upload File :
Create Path :
Current File : //proc/self/root/home/eirtvhdf/public_html/cart.php

<?php
session_start();
$pageTitle="My Cart";
$pagename="My Cart";
?>
<?php require("inc/header.php");
require("database.php"); 

if (isset($_GET['id'])){
      foreach ($_SESSION['cart'] as $key => $value){
          if($value["package_id"] == $_GET['id']){
              unset($_SESSION['cart'][$key]);
              echo "<script> window.onload = function() {
                    myfunction();
                    }; </script>";
                    
          }
      }
      echo "<script>location = 'cart.php?alert=1'</script>";
}

if (isset($_GET['alert'])){

    echo "<script> window.onload = function() {
                myfunction4();
                }; </script>";
}

?>





 
<!-- Central Modal Medium Info -->
 <div class="modal fade" id="myModal5" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
   aria-hidden="true">
   <div class="modal-dialog modal-notify modal-info" role="document">
     <!--Content-->
     <div class="modal-content">
       <!--Header-->

       <!--Body-->
       <div class="modal-body">
         <div class="text-center">
           <i style="color:#24bdc9;" class="fa fa-trash-o fa-4x mb-3 animated rotateIn"></i>
           <p>Package has been removed from the cart..!!</p>
         </div>
       </div>

       <!--Footer-->
     </div>
     <!--/.Content-->
   </div>
 </div>
 <!-- Central Modal Medium Info--> 
 
    <section style="padding-top:4em; padding-bottom:8em;" class="ftco-section bg-light">
    	<div class="container">
    		<div class="shopping-cart">
    		    </br>
                <h6>My Cart</h6>
                <hr>
                
                
   <?php
                
                $total = 0;
                $amount = 0;
                $quantity = 1;
                    if (!empty($_SESSION['cart'])){
                        ?>
                        <form action="cart.php" method="post">
                        <table class="table table-bordered">
                                        <tr style="background-color:#daf6f8;">
                                            <th>Package Name</th>
                                            <th>Price</th>
                                            <th></th>
                                        </tr>
                                       
                        
                        <?php
                        $package_id = array_column($_SESSION['cart'], 'package_id');

                        $sql = "SELECT * FROM Packages ORDER BY id DESC";
                        $result = mysqli_query($dbh,$sql) or die(mysqli_error($dbh));
                        while ($row = mysqli_fetch_assoc($result)){
                            foreach ($package_id as $id){
                                if ($row['id'] == $id){
                                  /*  cartElement($row['product_image'], $row['product_name'],$row['product_price'], $row['id']); */
                                    $total += $quantity * $row['Price']; 
                                    ?>
                                     <tr>
                                         <td><?php echo $row['Package']; ?></td>
                                        
                                         <td><?php echo '&#36; '.$row['Price']; ?></td>
                                         <td><a href="cart.php?id=<?php echo $row['id']; ?>" title="Remove"><span class="fa fa-close"></span></a></td>
                                         
                                         </tr>
                                    
                                    <?php
                                }

                            }
                        }
                    ?>
                    <tr style="background-color:#daf6f8;">
                                             <th colspan="3"><span style="padding-top:8px; float:right; font-size:20px;">Total</span></th>
                                             <td colspan="2"><span style="font-size:20px;"><?php echo '&#36; '.$total.'.00'; ?></span></td>
                                             </tr>
                    </table>
                    

<div style="float:right;">
    <a href="index.php#package" class="btn btn-info"/>Continue Shopping</a>
    <button type="button" class="btn btn-success" data-toggle="modal" data-target="#exampleModal1">Proceed to Checkout</button>
    </div>

    
    </form>
                    <?php
                    }
                    else{
                        echo "<h6>Cart is Empty</h6>";
                    }


									
   ?>
                                            




            </div>
    	</div>
    </section>
    
<?php
if(isset($_POST['submit'])){
    $name = $_POST['name'];
    $street = $_POST['street'];
    $city = $_POST['city'];
    $email = $_POST['email'];
    $contact = $_POST['contact'];
    $pwd = $_POST['pwd'];
    
    $mysqli = mysqli_query($dbh,"insert into users values('','$name','$email','$pwd','$contact','$street','$city')");
    $last_id = mysqli_insert_id($dbh);
    
    $package_id = array_column($_SESSION['cart'], 'package_id');

                        $sql = "SELECT * FROM Packages ORDER BY id DESC";
                        $result = mysqli_query($dbh,$sql) or die(mysqli_error($dbh));
    while ($row = mysqli_fetch_assoc($result)){
                            foreach ($package_id as $id){
                                if ($row['id'] == $id){
                                    $package = $row['Package'];
                                    $amount += $row['Price'];
                                    $price = $row['Price'];
                                    
                                    
                                    mysqli_query($dbh,"insert into cart_details values('','$last_id','$id','$package','$price')");
                                }

                            }
                        }
                $_SESSION['amount'] = $amount;
    echo "<script>location.href = 'index.php';</script>";                    
    
}



?>

    
    <div class="modal fade" id="exampleModal1" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel1" aria-hidden="true">
        <div style="max-width:650px; -webkit-box-shadow: 3px 10px 39px 2px rgba(0,0,0,0.75);
-moz-box-shadow: 3px 10px 39px 2px rgba(0,0,0,0.75);
box-shadow: 3px 10px 39px 2px rgba(0,0,0,0.75);" class="modal-dialog" role="document">
            <div class="modal-content">
                <div style="background-color:#78d5ef;" class="modal-header">
                    <h5 style="color:white;" class="modal-title" id="exampleModalLabel1">Personal Information</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <div class="modal-body">
                    <form  action="#" method="post">
					<div class="row">
                        <div class="form-group col-sm-12 col-md-12 col-lg-12">
							<label>Full Name</label>
							<input style="font-size:16px; height:45px; border-radius:10px;" required name="name" type="text" class="form-control" placeholder="Enter Name">
						</div>

						<div class="clearfix"></div>
					</div>
					
					<div class="row">
                        <div class="form-group col-xs-10 col-sm-7 col-md-7 col-lg-7">
							<label>Street</label>
							<input style="font-size:16px; height:45px; border-radius:10px;" required name="street" type="text" class="form-control" placeholder="Enter Street">
						</div>
						<div class="form-group col-xs-10 col-sm-5 col-md-5 col-lg-5">
							<label>City</label>
							<input style="font-size:16px; height:45px; border-radius:10px;" required name="city" type="text" class="form-control" placeholder="Enter City">
						</div>
						<div class="clearfix"></div>
					</div>
					
					<div class="row">
                        <div class="form-group col-xs-10 col-sm-6 col-md-6 col-lg-6">
							<label>Email Address</label>
							<input style="font-size:16px; height:45px; border-radius:10px;" required name="email" type="email" class="form-control" placeholder="Enter Email">
						</div>
						<div class="form-group col-xs-10 col-sm-6 col-md-6 col-lg-6">
							<label>Contact Number</label>
							<input style="font-size:16px; height:45px; border-radius:10px;" required name="contact" type="text" class="form-control" placeholder="Enter Contact">
						</div>
						<div class="clearfix"></div>
					</div>
					
					<div class="row">
                        <div class="form-group col-xs-10 col-sm-6 col-md-6 col-lg-6">
							<label>Create Password</label>
							<input style="font-size:16px; height:45px; border-radius:10px;" required name="pwd" type="password" class="form-control" placeholder="Enter Password">
						</div>
						<div class="clearfix"></div>
					</div>
					
					</br>
					

                     <center>   <div class="right-w3l">
                            <input type="submit" name="submit" class="btn btn-info" value="Submit Details">
                        </div></center>
                    </form>
                </div>
            </div>
        </div>
    </div>


<?php require("inc/footer.php"); ?>


<script>

function myfunction(){

        $("#myModal").modal('show');

}

function empty(){

        $("#myModal3").modal('show');

}

function myfunction1(){

        $("#myModal1").modal('show');

}

function myfunction4(){

        $("#myModal5").modal('show');

}

</script>

Zerion Mini Shell 1.0