query("SELECT * FROM users WHERE id = '" . $_POST["uid"] . "';")->fetchArray(SQLITE3_ASSOC); if(!$p_user || !$p_user["id"]){ echo "user not found"; die(); } $errorMsg = ""; if(isset($_POST["post-submit"])){ if($_POST["post-text"] == "") $errorMsg = "The question can't be blank."; else if(strlen($_POST["post-text"]) > 400) $errorMsg = "The question can't bee longer than 400 characters"; else{ $u = $p_user["id"]; $by = 0; $question = htmlspecialchars($_POST["post-text"], ENT_QUOTES); $priv = 0; if(isset($_SESSION["uid"]) && !$_POST["anon"]) $by = $_SESSION["uid"]; if($_POST["priv"]) $priv = 1; // Insert user into DB $db->exec("INSERT INTO questions(user,by,question,q_date,private) VALUES ('$u','$by','$question',". strtotime('now') .",$priv);"); unset($_POST["post-text"]); if($fancy_urls) header("Location: /user/" . $p_user["username"]); else header("Location: /user.php?q=" . $p_user["username"]); } } ?>