<?php
include("../sql.php");
$connectionInfo = array("Database" => "$dbname", "UID" => "$username", "PWD" => "$password", "CharacterSet" => "UTF-8");
$conn = sqlsrv_connect($hostname, $connectionInfo);
if ($conn === false) {
    die(print_r(sqlsrv_errors(), true));
    header("Location: ../../../edit.html?status=dbFailed");
}

if(isset($_POST["projectId"]) && isset($_POST["projectName"]) && isset($_POST["category"])){
    $sql =  "UPDATE [Project_Table] SET [project_name] = ?,[category_id] = ? WHERE [project_id] = ?";
    $stmt = sqlsrv_query($conn, $sql, array($_POST["projectName"], $_POST["category"],$_POST["projectId"]));
    header("Location: ../../../edit.html?status=success");
}else{
    header("Location: ../../../edit.html?status=postFailed");
}
sqlsrv_close($conn);