2
User.php
<?php
class User {
public static $Row = [];
public static function Check() {
global $PDO;
$usersql = $PDO->prepare("SELECT * FROM users WHERE username = :username AND password = :password LIMIT 1");
$usersql->execute(array(':username' => $_SESSION['username'], ':password' => $_SESSION['password']));
$Row = $usersql->fetch(PDO::FETCH_ASSOC);
self::$Row = $Row;
}
}
Index.php
echo 'Você é '. User::$Row['username'];
And error that gives:
Notice: Undefined index: username in C: xampp htdocs Index.php on line 1
He appears in the index.php
in Check()
, when I try to call user information gives this error.
Does anyone know how I fix?
you need to call the
check()
before :echo 'Você é '. User::$Row['username'];
– rray
Do it like this:
User::Check(); echo User::$Row['username'];
– rray
thanks rray, you saved my life!
– Tools
Please avoid long discussions in the comments; your talk was moved to the chat
– Math