Mini Kabibi Habibi
<?php
session_start();
if ($_SESSION['role'] != 'admin') {
header("Location: login.php");
exit();
}
include('db_connection.php');
if (isset($_POST['school_name'])) {
$school_name = $_POST['school_name'];
$school_type = $_POST['school_type'];
$username = $_POST['username'];
$password = $_POST['password'];
// Add school
$add_school_query = "INSERT INTO schools (name, school_type) VALUES ('$school_name', '$school_type')";
mysqli_query($conn, $add_school_query);
$school_id = mysqli_insert_id($conn);
// Add school user
$add_user_query = "INSERT INTO users (username, password, role, school_id) VALUES ('$username', '$password', 'school_user', '$school_id')";
mysqli_query($conn, $add_user_query);
header("Location: admin_dashboard.php");
}
?>
<form method="post" action="">
<input type="text" name="school_name" placeholder="School Name" required>
<select name="school_type">
<option value="Elementary">Elementary</option>
<option value="Integrated Elementary and Junior High School">Integrated Elementary and Junior High School</option>
<option value="Integrated Junior and Senior High School">Integrated Junior and Senior High School</option>
<option value="Stand Alone Senior High School">Stand Alone Senior High School</option>
</select>
<input type="text" name="username" placeholder="Username" required>
<input type="password" name="password" placeholder="Password" required>
<button type="submit">Add School</button>
</form>