Add anon and 404 page
This commit is contained in:
parent
5c39988fc7
commit
9247804208
19
user.php
19
user.php
|
@ -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();
|
||||
|
|
Loading…
Reference in New Issue