query("SELECT * FROM users WHERE username = '" . $_GET["q"] . "';")->fetchArray(SQLITE3_ASSOC); if(!$user || !$user["id"]){ include("404.php"); die(); } //else if(!$user["id"]){ // include("404.php"); // die(); //} $db->exec("CREATE TABLE IF NOT EXISTS questions( id INTEGER PRIMARY KEY, user INTEGER, by INTEGER, question TEXT );"); if(!$db->querySingle("SELECT EXISTS(SELECT * FROM users where id = 0);")){ echo "NOTICE: anonymous user created."; $db->exec("INSERT INTO users(id, username, name) VALUES('0','anonymous','Anonymous');"); } if($validUser){ header("Location: /"); 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 = $user["id"]; $by = 0; $question = htmlspecialchars($_POST["post-text"]); // Insert user into DB $db->exec("INSERT INTO questions(user,by,question) VALUES ('$u','$by','$question');"); unset($_POST["post-text"]); } } ?> <?= $user["username"] ?> | LibreCat

Ask me anything


$errorMsg

\n"; ?>
query("SELECT * FROM questions WHERE user = '" . $user["id"] . "' LIMIT 0, 10;"); while($current = $qs->fetchArray(SQLITE3_ASSOC)){ echo("

". $current["by"] ."

"); echo("

". $current["question"] ."

"); } ?>