<?php
require_once('dbconnection.php');
session_start();





if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $t_name = mysqli_real_escape_string($con, $_POST['t_name']);

    // Insert new teacher
    $query = "INSERT INTO teacher (t_name) VALUES ('$t_name')";

    if ($con->query($query)) {
        echo "<script>
            alert('استاد موفقانه ثبت شد');
            window.location.href='view_teacher.php';
        </script>";
    } else {
        echo "<script>
            alert('خطا در ثبت استاد: " . $con->error . "');
            window.history.back();
        </script>";
    }
}



?>