HEX
Server: Apache
System: Linux sg2plmcpnl492417.prod.sin2.secureserver.net 4.18.0-553.58.1.lve.el8.x86_64 #1 SMP Fri Jul 4 12:07:06 UTC 2025 x86_64
User: nyiet8349bzl (9207396)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: /home/nyiet8349bzl/www/oldwebsite.sbsc.in/faculty/admin/save-teacher.php
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);

include "../config/database.php";

if (!isset($_SESSION['admin_logged_in'])) {
    header("Location: login.php");
    exit;
}

/* FETCH TEACHER FOR EDIT */
$teacher = null;
if(isset($_GET['edit'])){
    $id = (int)$_GET['edit'];
    $stmt = $conn->prepare("SELECT name,email,department,designation FROM teachers WHERE id=?");
    $stmt->bind_param("i",$id);
    $stmt->execute();
    $stmt->bind_result($n,$e,$d,$des);
    $stmt->fetch();
    $stmt->close();

    $teacher = [
        'name'=>$n,
        'email'=>$e,
        'department'=>$d,
        'designation'=>$des
    ];
}
?>
<!DOCTYPE html>
<html>
<head>
    <title><?php echo $teacher ? "Edit Teacher" : "Add Teacher"; ?></title>

    <!-- OPEN SANS -->
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;600;700&display=swap" rel="stylesheet">

    <style>
        *{
            box-sizing:border-box;
            font-family:'Open Sans', sans-serif;
        }
        body{
            margin:0;
            background:#f6f7fb;
            display:flex;
        }

        /* SIDEBAR */
        .sidebar{
            width:220px;
            background:#1f2937;
            min-height:100vh;
            color:#fff;
            padding:20px;
        }
        .sidebar h3{
            margin:0 0 25px;
            font-size:18px;
            font-weight:600;
        }
        .sidebar a{
            display:block;
            color:#d1d5db;
            text-decoration:none;
            padding:10px 0;
            font-size:14px;
        }
        .sidebar a:hover{ color:#fff; }

        /* MAIN */
        .main{
            flex:1;
            padding:30px;
        }

        h2{
            margin:0 0 25px;
            font-weight:600;
        }

        /* FORM */
        .form-box{
            max-width:520px;
            background:#fff;
            border:1px solid #e5e7eb;
            padding:25px;
        }
        label{
            display:block;
            font-size:13px;
            margin-bottom:6px;
            font-weight:600;
        }
        input{
            width:100%;
            padding:10px;
            margin-bottom:18px;
            border:1px solid #ccc;
            font-size:13px;
        }

        .btn{
            padding:10px 18px;
            font-size:13px;
            text-decoration:none;
            border-radius:4px;
            border:1px solid transparent;
            cursor:pointer;
        }
        .btn-primary{
            background:#2563eb;
            color:#fff;
        }
        .btn-outline{
            background:#fff;
            border:1px solid #2563eb;
            color:#2563eb;
            margin-left:10px;
        }
    </style>
</head>
<body>

<!-- SIDEBAR -->
<div class="sidebar">
    <h3>Admin Panel</h3>
    <a href="dashboard.php">Dashboard</a>
    <a href="save-teacher.php">Add Teacher</a>
    <a href="logout.php">Logout</a>
</div>

<!-- MAIN -->
<div class="main">
    <h2><?php echo $teacher ? "Edit Teacher" : "Add Teacher"; ?></h2>

    <div class="form-box">
        <form method="post">
            <label>Full Name</label>
            <input name="name" required value="<?= $teacher['name'] ?? '' ?>">

            <label>Email</label>
            <input name="email" type="email" required value="<?= $teacher['email'] ?? '' ?>">

            <label>Department</label>
            <input name="department" required value="<?= $teacher['department'] ?? '' ?>">

            <label>Designation</label>
            <input name="designation" required value="<?= $teacher['designation'] ?? '' ?>">

            <label>Password</label>
            <input name="password"
                   placeholder="<?= $teacher ? 'Leave blank to keep same' : '' ?>"
                   <?= $teacher ? '' : 'required' ?>>

            <button class="btn btn-primary" name="save_teacher">
                <?= $teacher ? 'Update Teacher' : 'Save Teacher' ?>
            </button>

            <a href="dashboard.php" class="btn btn-outline">Cancel</a>
        </form>
    </div>
</div>

</body>
</html>