This commit is contained in:
nolanwhy 2023-02-12 11:21:19 +01:00
parent baf037c71f
commit fd034ca5fa
4 changed files with 30 additions and 14 deletions

View File

@ -7,12 +7,25 @@ class User {
public function __construct($con, $id) {
$query = $con->prepare('SELECT * FROM users WHERE id=:id');
$query->bindParam(':id', $id);
$query->execute();
$query->execute();
$this->con = $con;
$this->sqlData = $query->fetch(PDO::FETCH_ASSOC);
}
public static function isLoggedIn() {
return isset($_SESSION["user"]);
public function isLoggedIn() {
if(isset($_SESSION["user"])) {
$q = $this->con->prepare("SELECT * FROM users WHERE id = :id");
$q->bindParam(':id',$this->sqlData["id"],PDO::PARAM_INT);
$q->execute();
$usr = $q->fetch();
if($usr) {
return true;
} else {
return false;
}
} else {
return false;
}
}
public function getMoney($short) {

View File

@ -1,10 +1,13 @@
<?php
session_start();
if(isset($_SESSION['user'])) {
header("Location: /home");
}
require_once 'core/classes.php';
$user = new User($con, 0);
if($user->isLoggedIn()) {
header('location: /home');
exit;
}
$getitstarted = new PartyStarter;
$getitstarted->bootstrap();
$countofarray = rand(0, count($arraybackground)-1);

View File

@ -1,9 +1,5 @@
<?php
session_start();
if(isset($_SESSION['user'])) {
header("Location: /home");
}
require_once 'core/classes.php';
require_once 'core/classes/User.php';
require_once 'core/config.php';
@ -13,6 +9,10 @@ $getitstarted->header();
$passwordiswrong = false;
$userdontexist = false;
$user = new User($con, 0);
if($user->isLoggedIn()) {
header('location: /home');
exit;
}
if(isset($_POST['submit'])) {
$username = $_POST['username'];
$password = $_POST['pass'];

View File

@ -1,9 +1,5 @@
<?php
session_start();
if(isset($_SESSION['user'])) {
header("Location: /home");
}
require_once 'core/classes.php';
require_once 'core/classes/User.php';
require_once 'core/config.php';
@ -14,6 +10,10 @@ $usernamespecialchar = false;
$passwordconfirmiswrong = false;
$passwordistooshort = false;
$user = new User($con, 0);
if($user->isLoggedIn()) {
header('location: /home');
exit;
}
$userexists = false;
if(isset($_POST['submit'])) {
$username = $_POST['username'];