prepare("INSERT INTO Users (Users_username, Users_password, Users_admin) VALUES (:username, :password, :admin)"); $stmt->bindParam(":username", $username); $stmt->bindParam(":password", $password); $isAdmin = $admin ? 1 : 0; $stmt->bindParam(":admin", $isAdmin); $stmt->execute(); $logSQL = "INSERT INTO Logs (Logs_type, Users_username, Logs_date) VALUES (:type, :username, NOW())"; $logStmt = $conn->prepare($logSQL); $type = !$admin ? "Add user" : "Add admin"; $logStmt->bindParam(":type", $type); $logStmt->bindParam(":username", $_SESSION["username"]); $logStmt->execute(); echo json_encode(array("message" => "ok", "admin" => $admin)); } else if (isset($_SESSION["username"]) && !isset($_SESSION["admin"])) { echo json_encode(array("message" => "not logged in as admin")); } else { echo json_encode(array("message" => "Not logged in ")); }