-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
167 lines (157 loc) · 5.69 KB
/
index.php
File metadata and controls
167 lines (157 loc) · 5.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>BeSanta</title>
<link rel="stylesheet" href="index.css">
<style>
.navbuttons{
background-color:#E05D5D;
border:0px;
font-size: 95%;
margin-right:3%;
color:white;
font-weight: bold;
}
.item-list{
margin: 3% 3%;
align-items: center;
display: grid;
grid-template-columns: repeat(5,1fr);
grid-auto-rows:250px;
}
.item-block{
padding: 3% 2%;
margin: 5%;
width: 70%;
height: 200px;
background-color:white;
border-radius:20px;
box-shadow: 1px 1px grey;
}
.items-display{
margin: 0% 3%;
}
#search-bar{
padding: 6px 4px;
border-width:1px;
border-radius:10px;
}
</style>
</head>
<body>
<?php session_start(); ?>
<div class="header">
<div id="page-title">
<button type="button" name="home-button" id="home-button" onclick="document.location.href='index.php'"></button>
<div class="Account">
<?php
if(isset($_SESSION['uid'])){
echo $_SESSION['username'].
"<br><button class='buttons' onclick=\"window.location.href='logout.php'\">Logout</button>";
}
else{
echo "<button class='buttons' onclick=\"window.location.href='SignUp.html'\">Register</button>
<button class='buttons' onclick=\"window.location.href='SignIn.html'\">Log In</button>";
}
?>
</div>
<h1>BeSanta : Donation System</h1>
<p class="slogan">Let's be someone's Santa!</p>
</div>
</div>
<div class="nav-bar" style="background-color: #E05D5D; padding:5px;">
<button type="button" name="who_can_donate" id="who" class="navbuttons" onclick="window.location.href='whoCanDonate.html'">WHO CAN DONATE</button>
<button type="button" name="what_to_donate" id="what" class="navbuttons" onclick="window.location.href='whatToDonate.html'">WHAT TO DONATE</button>
<button type="button" name="How_to_donate" id="how" class="navbuttons" onclick="window.location.href='HowToDonate.html'">HOW TO DONATE</button>
</div>
<div class="main-container">
<br>
<div class="block-buttons-section" id="edit-block-button">
<!--<button type="button" class="bigButtons" name="search-item-button" id="search-item" onclick="window.location.href='Search-Display.php'">SEARCH<br>ITEM<br></button>-->
<button type="button" class="bigButtons" name="add-item-button" id="add-item" onclick="window.location.href='AddItem.html'">DONATE<br>ITEM<br></button>
<button type="button" class="bigButtons" name="delete-item-button" id="delete-item" onclick="window.location.href='DeleteItem.html'">DELETE<br>ITEM<br></button>
<button type="button" class="bigButtons" name="update-item-button" id="update-item" onclick="window.location.href='UpdateItem.html'">UPDATE<br>ITEM<br></button>
</div><br>
<div id="items-display" class="items-display">
<h2>Items List</h2>
<div class="Search">
<form action="" method="POST">
<label>Search </label>
<input type="search" id="search-bar" name="search" placeholder=" search your products here" style="width:20%;">
<input type="submit" id="search-submit" value="🔍" style="border:0px; background-color:inherit;">
</form>
</div>
<div class="item-list">
<?php
$conn = mysqli_connect('localhost','root','','donationsystem');
if($conn){
if(isset($_POST['search'])){
$search = $_POST['search'];
$stmt = $conn->prepare("select * from items where item_name = ?");
$stmt->bind_param("s",$search);
$stmt->execute();
$result = $stmt->get_result();
if($result->num_rows > 0){
while($row = $result->fetch_assoc()){
echo "<div class='item-block'>".
$row["item_name"]."<br>".
$row["category"]."<br>".
$row["brand"]."<br>".
$row["quantity"]."<br>".
$row["item_weight"]."<br>"
."</div>";
}
}
else{
echo "No search results";
}
}
else{
$query = "select * from items";
$result = $conn->query($query);
if($result->num_rows > 0)
{
while($row = $result->fetch_assoc()){
echo "<div class='item-block'>".
$row["item_name"]."<br>".
$row["category"]."<br>".
$row["brand"]."<br>".
$row["quantity"]."<br>".
$row["item_weight"]."<br>"
."</div>";
}
}
else{
echo "No items available";
}
}
}
else{
echo "Connection Failed!";
}
$conn->close();
?>
</div>
</div><br>
</div>
<div class="footer" id="page-footer">
<div class="" id="aboutus">
<h3>About Us</h3>
<p style="position:relative;">
We, the team of BeSanta are from Goa, India who help you find the right people for you to donate through this Website
</p><br>
</div>
<div class="" id="Quicklinks">
<h3>Quick Links</h3>
<p>
<a class="links" href="contact.html">Contact Us</a>
<a class="links" href="Search-Display.html">Search Items</a>
<a class="links" href="AddItem.html">Add Item</a>
<a class="links" href="DeleteItem.html">Delete Items</a>
<a class="links" href="UpdateItem.html">Update Items</a>
</p>
</div><br>
</div>
</body>
</html>