query("SELECT * FROM questions WHERE id = '" . $_GET["q"] . "';")->fetchArray(SQLITE3_ASSOC); if(!$question || !$question["id"]){ echo("Question not found."); die(); } else if($question["user"] != $_SESSION["uid"]){ echo("You have no permission to answer this question."); die(); } if(isset($_POST["answered"])){ if($_POST["answer_body"] == ""){ echo("Answer cannot be blank."); } else{ $db->exec("UPDATE questions SET answer = '" . htmlspecialchars($_POST["answer_body"], ENT_QUOTES) . "', a_date = " . strtotime("now") . " WHERE id = " . $_GET["q"] . ";"); if($pretty_urls){ header("Location: /user/" . $db->querySingle("SELECT username FROM users WHERE id = " . $question["user"] . ";")); die(); } else{ header("Location: /user.php?q=" . $db->querySingle("SELECT username FROM users WHERE id = " . $question["user"] . ";")); die(); } } } } ?>