Add anon and 404 page

This commit is contained in:
posweg 2020-05-21 08:07:28 +00:00
parent 5c39988fc7
commit 9247804208
2 changed files with 13 additions and 7 deletions

1
404.php Normal file
View File

@ -0,0 +1 @@
ERROR 404: Page not found

View File

@ -2,6 +2,14 @@
$db = new SQLite3('ask.db');
$user = $db->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,
@ -10,13 +18,10 @@ $db->exec("CREATE TABLE IF NOT EXISTS questions(
question TEXT
);");
//if(!$db->querySingle("SELECT * FROM users where id = 0;")){
// echo "ta;yf";
// $db->exec()
//}
//else{
// echo "tft;y";
//}
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();