Skip to content

Commit 3effe56

Browse files
add cart
1 parent 26ef0d4 commit 3effe56

File tree

8 files changed

+219
-1
lines changed

8 files changed

+219
-1
lines changed

addproductdb.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
echo "data inserted successfully<BR>";
2626
mysqli_close($con);
2727

28+
?>
2829

30+
<form action="addproduct.php" method="POST">
31+
<input type="hidden" name="addproduct" value=1>
32+
<input type="submit" value="Add more Product">
33+
</form>
34+
35+
<?php
2936

3037
}
3138
?>

addtocart.php

Whitespace-only changes.

authenticatecustomer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
echo "Unsuccessful";
1717
}
1818

19+
1920
$email = $_POST["email"];
2021
$loginpassword = $_POST["loginpassword"];
2122

cart.php

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
<?php
2+
// connecting to database
3+
$servername = "localhost";
4+
$username = "root";
5+
$password = "";
6+
$database = "charliestore";
7+
8+
// create a connection
9+
$con = mysqli_connect($servername, $username, $password, $database);
10+
11+
?>
12+
13+
<!doctype html>
14+
<html lang="en">
15+
<head>
16+
<!-- Required meta tags -->
17+
<meta charset="utf-8">
18+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
19+
20+
<!-- Bootstrap CSS -->
21+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
22+
23+
<!-- Font awesome link -->
24+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
25+
26+
<title>Products</title>
27+
</head>
28+
<body>
29+
30+
31+
32+
<div class="container">
33+
<div class="row justify-content-center">
34+
<div class="col-lg-11">
35+
<div class="table responsive mt-2">
36+
<table class="table table-bordered table-striped text-center">
37+
<thead>
38+
<tr>
39+
<td colspan="7">
40+
<h3 text-center> Your Products!</h3>
41+
</td>
42+
</tr>
43+
<tr>
44+
<th>Name</th>
45+
<th>Image</th>
46+
<th>Quantity</th>
47+
<th>Price</th>
48+
<th>Tax</th>
49+
<th>GST</th>
50+
<!-- get request -->
51+
<th><a onclick="return confirm('Are you sure you want to clear your cart? ')" href="action.php?clear=all" class="badge badge-danger"><i class="fa fa-trash"></i> Clear cart</a></th></tr>
52+
</thead>
53+
<tbody>
54+
55+
<?php
56+
// $id = $_GET['productid'];
57+
$query = "SELECT * FROM `products`";
58+
$result = mysqli_query($con, $query);
59+
// $result->num_rows>0
60+
$total=0;
61+
while($row = mysqli_fetch_assoc($result)):
62+
63+
$productname = $row["productname"];
64+
$priceperunit = number_format($row["priceperunit"],2);
65+
$manufacturingdate = $row["manufacturingdate"];
66+
$inventoryquantity = $row["inventoryquantity"];
67+
$productimage = $row["productimage"];
68+
$id = $row["productid"];
69+
70+
?>
71+
<tr>
72+
<td><input type="text" class="form-control text-center" value="<?php echo $productname ?>"></td>
73+
<td><input type="text" class="form-control text-center" width="50" value="<?php echo $productimage ?>"></td>
74+
<td><input type="number" class="form-control text-center" min="1" value="<?php echo $inventoryquantity ?>"></td>
75+
<td><input type="text" class="form-control text-center" value="<?php echo $priceperunit ?>" disabled></td>
76+
<td><input type="text" class="form-control" id="gst" disabled></td>
77+
<td><input type="text" class="form-control" id="total" name="total" disabled></td>
78+
<td><a href="action.php?delete=<?php $id?>" class="text-danger"><i class="fa fa-trash"></i> </a></td>
79+
80+
<?php endwhile;?>
81+
82+
83+
<tr><td colspan="3"><a href="product.php" class="btn btn-success"><i class="fa fa-cart-plus"></i> Continue Shopping</a></td>
84+
<td colspan="2" class="mt-2">Amount to be paid</td>
85+
<td><i class="fa fa-rupee"></i> <?php echo number_format($total,2)?></td>
86+
<!-- go for payment -->
87+
<td><a href="" class="btn btn-info"><i class="fa fa-credit-card"></i>Pay</a></td>
88+
</tr>
89+
</tr>
90+
</tbody>
91+
</table>
92+
</div>
93+
</div>
94+
</div>
95+
</div>
96+
97+
98+
<!-- Optional JavaScript -->
99+
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
100+
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
101+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
102+
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
103+
</body>
104+
</html>

customerlogin.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
1111
<form action="authenticatecustomer.php" method="POST">
1212
<table>
13-
<tr >
13+
<tr>
1414
<td class="email">
1515
Email:
1616
</td>
@@ -44,3 +44,5 @@
4444
</td>
4545
</tr>
4646
</table>
47+
</body>
48+
</html>

customerviewproduct.css

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
*{
2+
margin:0;
3+
padding:0;
4+
}
5+
.card{
6+
width: 25%;
7+
background-color: skyblue;
8+
border-radius: 5px;
9+
box-shadow: 1px 1px 5px black;
10+
font-family: 'Bebas Neue', cursive;
11+
}
12+
.card:hover{
13+
box-shadow: 2px 2px 10px black;
14+
}
15+
img{
16+
width: 100%;
17+
border-radius: 5px 5px 0 0;
18+
}
19+
.cost{
20+
padding-top: 10px;
21+
padding-bottom: 10px;
22+
text-align: center;
23+
font-size: 20px;
24+
}
25+
.name{
26+
text-align: center;
27+
font-size: 20px;
28+
}
29+
.btn{
30+
text-align: center;
31+
margin-top: 20px;
32+
padding-bottom: 20px;
33+
34+
}
35+
input{
36+
border-radius: 15px;
37+
background-color: springgreen;
38+
font-family: 'Bebas Neue', cursive;
39+
font-size: 20px;
40+
padding:5px 10px
41+
}

customerviewproduct.php

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<link rel="stylesheet" href="customerviewproduct.css">
7+
<link href="https://fonts.googleapis.com/css2?family=Bebas+Neue&display=swap" rel="stylesheet">
8+
<title>Buy Products</title>
9+
</head>
10+
11+
<body>
12+
13+
<?php
14+
15+
16+
$conn = new mysqli("localhost", "root", "", "charliestore");
17+
if ($conn->connect_error)
18+
die("Connection failed: " . $conn->connect_error);
19+
else
20+
{
21+
$sql="select * from products" ;
22+
$r=mysqli_query($conn,$sql);
23+
24+
while($row = mysqli_fetch_assoc($r))
25+
{
26+
?>
27+
28+
29+
<div class="card">
30+
<!-- <div class="image">
31+
<img src="productpic.jpg" alt="#" style="width:100%">
32+
</div> -->
33+
<div class="cost">
34+
<h3>Per Piece Cost:
35+
<?php
36+
37+
echo $row["priceperunit"];
38+
39+
?></h3>
40+
</div>
41+
<div class="name">
42+
<p><?php echo $row["productname"]; ?></p>
43+
</div>
44+
<div class="btn">
45+
<form action=addtocart.php method="post">
46+
<input type="hidden" name="productid" value=<?php echo $row["productid"]; ?>>
47+
<input type="number" name="orderquantity" placeholder="Quantity" >
48+
<input type="submit" value="Add to cart">
49+
</form>
50+
</div>
51+
</div>
52+
53+
<?php
54+
}
55+
}
56+
mysqli_close($conn);
57+
58+
?>
59+
60+
61+
62+
</body>
63+
</html>

productpic.jpg

1.53 MB
Loading

0 commit comments

Comments
 (0)