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');
|
$db = new SQLite3('ask.db');
|
||||||
|
|
||||||
$user = $db->query("SELECT * FROM users WHERE username = '" . $_GET["q"] . "';")->fetchArray(SQLITE3_ASSOC);
|
$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(
|
$db->exec("CREATE TABLE IF NOT EXISTS questions(
|
||||||
id INTEGER PRIMARY KEY,
|
id INTEGER PRIMARY KEY,
|
||||||
|
@ -10,13 +18,10 @@ $db->exec("CREATE TABLE IF NOT EXISTS questions(
|
||||||
question TEXT
|
question TEXT
|
||||||
);");
|
);");
|
||||||
|
|
||||||
//if(!$db->querySingle("SELECT * FROM users where id = 0;")){
|
if(!$db->querySingle("SELECT EXISTS(SELECT * FROM users where id = 0);")){
|
||||||
// echo "ta;yf";
|
echo "NOTICE: anonymous user created.";
|
||||||
// $db->exec()
|
$db->exec("INSERT INTO users(id, username, name) VALUES('0','anonymous','Anonymous');");
|
||||||
//}
|
}
|
||||||
//else{
|
|
||||||
// echo "tft;y";
|
|
||||||
//}
|
|
||||||
|
|
||||||
if($validUser){
|
if($validUser){
|
||||||
header("Location: /"); die();
|
header("Location: /"); die();
|
||||||
|
|
Loading…
Reference in New Issue