<?php
require "../Pages/UserAdmin/super_secret_stuff.php";
require "CommonFunc.php";
if(!empty($_GET["auth"]) && !empty($_GET["pid"]) && !empty($_GET["mname"])){
  $con = mysqli_connect($website,$mysqli_username,$pw,$dbase);

  $auth = $_GET["auth"];
  $user_id = userid($con,$auth);
  if($user_id <= 0)goto errormsg;

  $projid = $_GET["pid"];
  $pid = projid($con,$projid,$user_id);
  if($pid <= 0)goto errormsg;

  $mname = $_GET["mname"];
  if($mname == "")$mname = "cannot use blank model name";

  mysqli_query($con,"UPDATE calibro_projects SET name='{$mname}' WHERE calproj_id = {$pid}");
  mysqli_close($con);
}else{
  echo ("ERROR in EditModelName.php: authentication code or project id or new model name not provided!");
}
exit;

errormsg:
echo ("ERROR in EditModelName.php: bad authentication code or project id");
mysqli_close($con);
exit;
?>
