2024-05-15 19:18:15 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
require_once "lib/account.php";
|
|
|
|
function submitSurvey(int $satisfaction, int $functionality, int $content, string $comment): array
|
|
|
|
{
|
|
|
|
global $mysqli;
|
|
|
|
$output = ["Status" => "Fail", "Opinion" => "Ignored unsuccessfully!"];
|
|
|
|
if (isLoggedIn()
|
|
|
|
&& $satisfaction >= 1 && $satisfaction <= 5
|
|
|
|
&& $functionality >= 1 && $functionality <= 5
|
|
|
|
&& $content >= 1 && $content <= 5
|
|
|
|
&& !empty($comment)) {
|
|
|
|
$stmtMemeAdd = $mysqli->prepare('INSERT INTO Survey (AuthorID, Satisfaction, Functionality, Content, Comment) VALUES (?, ?, ?, ?, ?)');
|
2024-05-15 19:42:11 +02:00
|
|
|
$stmtMemeAdd->bind_param('iiiis', $_SESSION['ID'], $satisfaction, $functionality, $content, htmlspecialchars($comment));
|
2024-05-15 19:18:15 +02:00
|
|
|
if ($stmtMemeAdd->execute() && $stmtMemeAdd->affected_rows > 0) {
|
|
|
|
$output["Status"] = "Success";
|
|
|
|
$output["Opinion"] = "Ignored successfully!";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $output;
|
|
|
|
}
|