| Server IP : 173.209.174.21 / Your IP : 216.73.216.89 Web Server : Apache/2.4.58 (Ubuntu) System : Linux wcfs-server 6.8.0-124-generic #124-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 13:00:45 UTC 2026 x86_64 User : nodor ( 1000) PHP Version : 8.3.6 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/wcsd/School-alert/Backup files/ |
Upload File : |
<?php
session_start();
require 'config/db.php';
// Enable error reporting
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Check if the user is logged in and has admin privileges
if (!isset($_SESSION['user_id']) || $_SESSION['role'] !== 'admin') {
header('Location: dashboard.php');
exit();
}
// Fetch current school info
$school_id = $_SESSION['school_id'];
$stmt = $pdo->prepare("SELECT * FROM schools WHERE school_id = ?");
$stmt->execute([$school_id]);
$school = $stmt->fetch(PDO::FETCH_ASSOC);
// Handle form submission
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
$name = $_POST['name'];
$address = $_POST['address'];
$phone = $_POST['phone'];
$notification_emails = $_POST['notification_emails'];
try {
// Update the school info in the database
$stmt = $pdo->prepare("UPDATE schools SET name = ?, address = ?, phone = ?, notification_emails = ? WHERE school_id = ?");
$stmt->execute([$name, $address, $phone, $notification_emails, $school_id]);
// Redirect back to the dashboard with a success message
header('Location: dashboard.php?message=School information updated successfully');
exit();
} catch (PDOException $e) {
echo "Error updating school information: " . $e->getMessage();
}
}
?>
<?php include __DIR__ . '/views/header.php'; ?>
<h2>Edit School Information</h2>
<form method="POST" action="profile.php">
<label for="name">School Name:</label>
<input type="text" id="name" name="name" value="<?= htmlspecialchars($school['name']) ?>" required>
<label for="address">Address:</label>
<input type="text" id="address" name="address" value="<?= htmlspecialchars($school['address']) ?>" required>
<label for="phone">Phone:</label>
<input type="text" id="phone" name="phone" value="<?= htmlspecialchars($school['phone']) ?>" required>
<label for="notification_emails">Notification Emails (separate with commas):</label>
<textarea id="notification_emails" name="notification_emails" rows="3" required><?= htmlspecialchars($school['notification_emails']) ?></textarea>
<button type="submit">Update Information</button>
</form>
<?php include __DIR__ . '/views/footer.php'; ?>