Gazelle/sections/questions/take_answer_question.php

40 lines
923 B
PHP
Raw Normal View History

2013-10-13 08:01:01 +00:00
<?
authorize();
if (!check_perms("users_mod")) {
error(403);
}
$ID = $_POST['id'];
$Answer = db_string($_POST['answer']);
$Date = sqltime();
$UserID = $LoggedUser['ID'];
if (!is_number($ID) || empty($Answer)) {
error(404);
}
2013-10-14 08:00:53 +00:00
$DB->query("
SELECT 1
FROM staff_answers
WHERE QuestionID = '$ID'
AND UserID = '$LoggedUser[ID]'");
2013-10-13 08:01:01 +00:00
if (!$DB->has_results()) {
$DB->query("
2013-10-14 08:00:53 +00:00
INSERT INTO staff_answers
(QuestionID, UserID, Answer, Date)
VALUES
('$ID', '$UserID', '$Answer', '$Date')");
$DB->query("
SELECT UserID
FROM user_questions
WHERE ID = '$ID'");
2013-10-13 08:01:01 +00:00
list($ToID) = $DB->next_record();
2014-02-27 08:00:30 +00:00
Misc::send_pm($ToID, 0, "Your question has been answered", "One of your questions has been answered! View the response [url=". site_url() . "questions.php?action=view_answers&userid=$UserID#question$ID]here[/url].");
2013-10-13 08:01:01 +00:00
} else {
error("You have already answered this question");
}
header("Location: questions.php");