diff --git a/src/Controller/RequestController.php b/src/Controller/RequestController.php index 13ecbf2..2db8c87 100644 --- a/src/Controller/RequestController.php +++ b/src/Controller/RequestController.php @@ -361,14 +361,14 @@ class RequestController function handleDomainPostRequest(): void { $name = $_POST['name'] ?? ''; - $panelID = intval(value: $_POST['panel_id'] ?? 0); + $panel = $_POST['panel'] ?? ''; $content = $_POST['content'] ?? ''; if (empty($name)) { $this->header = "400 Bad Request"; $this->status = "400 Bad Request"; $this->message = "A name is required"; } else { - if (empty($a) && empty($aaaa) && empty($panelID)) { + if (empty($a) && empty($aaaa) && empty($panel)) { $this->header = "400 Bad Request"; $this->status = "400 Bad Request"; $this->message = "At least one IP address or panel ID is required."; @@ -379,9 +379,14 @@ class RequestController $this->message = "Domain: $name already exists."; } else { $domain = new Domain(name: $name, content: $content); - $result = $this->domainRepository->insert(domain: $domain); - $this->status = "201 Created"; - $this->message = $result; + if ($result = $this->domainRepository->insert(domain: $domain)) { + $this->status = "201 Created"; + $this->message = $result; + } else { + $this->header = "500 Server error"; + $this->status = "500 Server error"; + $this->message = $result; + } } } }