Here's an example of a school fees system in PHP using a MySQL database. This is just a basic example, and you may need to modify it to fit your specific requirements.
First, create a MySQL database with a table for fees payments:
SQLCREATE TABLE fees_payments (
id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
student_id INT(11) NOT NULL,
amount DECIMAL(10,2) NOT NULL,
date_paid DATE NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);
Then, create a PHP script to handle adding new fees payments:
PHP<?php
// Connect to the database
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "myDB";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Get the form data
$student_id = $_POST['student_id'];
$amount = $_POST['amount'];
$date_paid = $_POST['date_paid'];
// Insert the fees payment into the database
$sql = "INSERT INTO fees_payments (student_id, amount, date_paid)
VALUES ('$student_id', '$amount', '$date_paid')";
if ($conn->query($sql) === TRUE) {
echo "Fees payment added successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
You can then create a form in HTML to collect the necessary information and submit it to the PHP script:
HTML<form method="POST" action="add_fees_payment.php">
<label for="student_id">Student ID:</label>
<input type="text" name="student_id" id="student_id">
<label for="amount">Amount:</label>
<input type="text" name="amount" id="amount">
<label for="date_paid">Date Paid:</label>
<input type="date" name="date_paid" id="date_paid">
<input type="submit" value="Add Payment">
</form>
This is just a basic example to get you started. You may need to add additional functionality, such as displaying fees balances, generating reports, and handling different types of payments.