Skip to content

Commit 70124ee

Browse files
committed
Complete database
1 parent 7ea72f6 commit 70124ee

21 files changed

+715
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.DS_Store

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,29 @@
1-
# bloodmatch-dbms
2-
Make it easier to find blood
1+
# BloodMatch
2+
Making it easier to find blood
3+
4+
## Project Overview
5+
6+
BloodMatch is a comprehensive Blood Donation Management System developed using PHP and MySQL. It facilitates the management of blood donors, recipients, blood banks, and donation events, making the process of blood donation and distribution more efficient.
7+
8+
## Setup Instructions
9+
10+
1. Clone the repository.
11+
2. Import the `blood_donation.sql` file to set up the database.
12+
3. Configure the database connection in `includes/db_connect.php`.
13+
4. Place the project folder in your web server directory (e.g., `htdocs` for XAMPP).
14+
5. Access the project via your web browser.
15+
16+
## Folder Structure
17+
18+
- `css/`: Contains the CSS files.
19+
- `js/`: Contains the JavaScript files.
20+
- `includes/`: Contains the database connection file.
21+
- `donors/`: Contains scripts related to donor management.
22+
- `recipients/`: Contains scripts related to recipient management.
23+
- `blood_banks/`: Contains scripts related to blood bank management.
24+
- `donations/`: Contains scripts related to donation management.
25+
- `index.php`: Main entry point of the application.
26+
27+
## Usage
28+
29+
Navigate to the home page and use the links to manage donors, recipients, blood banks, and donations.

blood_banks/add_blood_bank.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
include('../includes/db_connect.php');
3+
4+
ini_set('display_errors', 1);
5+
error_reporting(E_ALL);
6+
7+
if ($_SERVER["REQUEST_METHOD"] == "POST") {
8+
$group = $_POST["group"];
9+
$amount = $_POST["amount"];
10+
$phone = $_POST["phone"];
11+
$location = $_POST["location"];
12+
13+
// Fetch the highest ID currently in use and add 1
14+
$stmt = $conn->prepare("SELECT MAX(id) AS max_id FROM blood_bank");
15+
$stmt->execute();
16+
$row = $stmt->fetch(PDO::FETCH_ASSOC);
17+
$next_id = (int)$row['max_id'] + 1;
18+
19+
// Prepare the SQL statement with the new ID
20+
$stmt = $conn->prepare("INSERT INTO blood_bank (id, `group`, amount, phone, location) VALUES (?, ?, ?, ?, ?)");
21+
$stmt->bindParam(1, $next_id, PDO::PARAM_INT);
22+
$stmt->bindParam(2, $group, PDO::PARAM_STR);
23+
$stmt->bindParam(3, $amount, PDO::PARAM_STR);
24+
$stmt->bindParam(4, $phone, PDO::PARAM_STR);
25+
$stmt->bindParam(5, $location, PDO::PARAM_STR);
26+
27+
if ($stmt->execute()) {
28+
echo "New blood bank added successfully with ID " . $next_id;
29+
} else {
30+
echo "Error: " . join(", ", $stmt->errorInfo());
31+
}
32+
33+
$stmt->closeCursor();
34+
}
35+
?>
36+
37+
<!DOCTYPE html>
38+
<html>
39+
<body>
40+
41+
<h2>Blood Bank Registration Form</h2>
42+
43+
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
44+
Blood Group:<br>
45+
<input type="text" name="group">
46+
<br>
47+
Amount:<br>
48+
<input type="text" name="amount">
49+
<br>
50+
Phone:<br>
51+
<input type="text" name="phone">
52+
<br>
53+
Location:<br>
54+
<input type="text" name="location">
55+
<br><br>
56+
<input type="submit" value="Submit">
57+
</form>
58+
59+
</body>
60+
</html>

blood_banks/list_blood_banks.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
include('../includes/db_connect.php');
3+
4+
$stmt = $conn->prepare("SELECT id, `group`, amount, phone, location FROM blood_bank");
5+
$stmt->execute();
6+
7+
if ($stmt->rowCount() > 0) {
8+
echo "<table><tr><th>ID</th><th>Blood Group</th><th>Amount</th><th>Phone</th><th>Location</th></tr>";
9+
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
10+
echo "<tr><td>".$row["id"]."</td><td>".$row["group"]."</td><td>".$row["amount"]."</td><td>".$row["phone"]."</td><td>".$row["location"]."</td></tr>";
11+
}
12+
echo "</table>";
13+
} else {
14+
echo "0 results";
15+
}
16+
$conn = null;
17+
?>
18+
19+
<!DOCTYPE html>
20+
<html>
21+
<body>
22+
23+
<h2>Blood Bank List</h2>
24+
25+
</body>
26+
</html>

blood_banks/search_blood_banks.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
include('../includes/db_connect.php');
3+
4+
if ($_SERVER["REQUEST_METHOD"] == "POST") {
5+
$group = $_POST["group"];
6+
$stmt = $conn->prepare("SELECT id, `group`, amount, phone, location FROM blood_bank WHERE `group` = ?");
7+
$stmt->bindParam(1, $group, PDO::PARAM_STR);
8+
$stmt->execute();
9+
10+
if ($stmt->rowCount() > 0) {
11+
echo "<table><tr><th>ID</th><th>Blood Group</th><th>Amount</th><th>Phone</th><th>Location</th></tr>";
12+
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
13+
echo "<tr><td>".$row["id"]."</td><td>".$row["group"]."</td><td>".$row["amount"]."</td><td>".$row["phone"]."</td><td>".$row["location"]."</td></tr>";
14+
}
15+
echo "</table>";
16+
} else {
17+
echo "0 results";
18+
}
19+
$conn = null;
20+
}
21+
?>
22+
23+
<!DOCTYPE html>
24+
<html>
25+
<body>
26+
27+
<h2>Search Blood Banks</h2>
28+
29+
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
30+
Blood Group:<br>
31+
<input type="text" name="group">
32+
<br><br>
33+
<input type="submit" value="Search">
34+
</form>
35+
36+
</body>
37+
</html>

check_insertion.sql

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Check data in blood_bank table
2+
SELECT * FROM blood_donation.blood_bank;
3+
4+
-- Check data in donor table
5+
SELECT * FROM blood_donation.donor;
6+
7+
-- Check data in hospital table
8+
SELECT * FROM blood_donation.hospital;
9+
10+
-- Check data in recipient table
11+
SELECT * FROM blood_donation.recipient;
12+
13+
-- Check data in donation_event table
14+
SELECT * FROM blood_donation.donation_event;
15+
16+
-- Check data in donor_has_recipient table
17+
SELECT * FROM blood_donation.donor_has_recipient;
18+
19+
-- Check data in order table
20+
SELECT * FROM blood_donation.`order`;

company.mwb

18.1 KB
Binary file not shown.

css/styles.css

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
body {
2+
font-family: Arial, sans-serif;
3+
}
4+
5+
h1, h2 {
6+
color: #333;
7+
}
8+
9+
ul {
10+
list-style-type: none;
11+
padding: 0;
12+
}
13+
14+
ul li {
15+
margin: 5px 0;
16+
}
17+
18+
ul li a {
19+
text-decoration: none;
20+
color: #0066cc;
21+
}
22+
23+
ul li a:hover {
24+
text-decoration: underline;
25+
}
26+
27+
table {
28+
width: 100%;
29+
border-collapse: collapse;
30+
}
31+
32+
table, th, td {
33+
border: 1px solid #ddd;
34+
}
35+
36+
th, td {
37+
padding: 8px;
38+
text-align: left;
39+
}
40+
41+
th {
42+
background-color: #f2f2f2;
43+
}

donations/add_donation.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
include('../includes/db_connect.php');
3+
4+
if ($_SERVER["REQUEST_METHOD"] == "POST") {
5+
$donor_id = $_POST["donor_id"];
6+
$bloodBank_id = $_POST["bloodBank_id"];
7+
8+
$stmt = $conn->prepare("INSERT INTO donation_event (donor_id, bloodBank_id) VALUES (?, ?)");
9+
$stmt->bindParam(1, $donor_id, PDO::PARAM_INT);
10+
$stmt->bindParam(2, $bloodBank_id, PDO::PARAM_INT);
11+
12+
if ($stmt->execute()) {
13+
echo "New donation recorded successfully";
14+
} else {
15+
echo "Error: " . join(", ", $stmt->errorInfo());
16+
}
17+
$conn = null;
18+
}
19+
?>
20+
21+
<!DOCTYPE html>
22+
<html>
23+
<body>
24+
25+
<h2>Record a Donation</h2>
26+
27+
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
28+
Donor ID:<br>
29+
<input type="number" name="donor_id">
30+
<br>
31+
Blood Bank ID:<br>
32+
<input type="number" name="bloodBank_id">
33+
<br><br>
34+
<input type="submit" value="Submit">
35+
</form>
36+
37+
</body>
38+
</html>

donations/list_donations.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
include('../includes/db_connect.php');
3+
4+
$stmt = $conn->prepare("SELECT donor_id, bloodBank_id FROM donation_event");
5+
$stmt->execute();
6+
7+
if ($stmt->rowCount() > 0) {
8+
echo "<table><tr><th>Donor ID</th><th>Blood Bank ID</th></tr>";
9+
while($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
10+
echo "<tr><td>".$row["donor_id"]."</td><td>".$row["bloodBank_id"]."</td></tr>";
11+
}
12+
echo "</table>";
13+
} else {
14+
echo "0 results";
15+
}
16+
$conn = null;
17+
?>
18+
19+
<!DOCTYPE html>
20+
<html>
21+
<body>
22+
23+
<h2>Donation List</h2>
24+
25+
</body>
26+
</html>

0 commit comments

Comments
 (0)