<?php
include("../includes/db_connection.php");
include("../includes/auth.php");

$id = intval($_POST['id'] ?? 0);
$name = trim($_POST['name']);
$status = $_POST['status'];

if($id>0){
$stmt=$conn->prepare("UPDATE standards SET name=?, status=? WHERE id=?");
$stmt->bind_param("ssi",$name,$status,$id);
}else{
$stmt=$conn->prepare("INSERT INTO standards (name,status) VALUES (?,?)");
$stmt->bind_param("ss",$name,$status);
}

$stmt->execute();
header("Location: standards.php");
exit;
?>