всегда возвращает последнюю id
<?php
class Login
{
protected $id;
public function Login()
{
$msg = '';
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
$json = $firebase->get(DEFAULT_PATH . "/ARCusers/");
$json_ary = json_decode($json, true);
if (is_array($json_ary) || is_object($json_ary)) {
foreach ($json_ary as $this->id => $val) {
$getEmail = $firebase->get(DEFAULT_PATH . "/ARCusers/$this->id/email");
$getPassword = $firebase->get(DEFAULT_PATH . "/ARCusers/$this->id/password");
$activation = $firebase->get(DEFAULT_PATH . "ARCusers/$this->id/activation");
if (isset($_POST['login']) && !empty($_POST['email'])
&& !empty($_POST['password'])
) {
if ('"' . $_POST['email'] . '"' == $getEmail &&
'"' . $_POST['password'] . '"' == $getPassword
) {
$_SESSION['valid'] = true;
$_SESSION['timeout'] = time();
$_SESSION['email'] = '"' . $_POST['email'] . '"';
if ($activation == 'true') {
echo "Logged in.";
header("Location: newwelcome.php");
// echo "$this->id";
return $this->id;
} else {
echo "verify your email";
}
} else {
$msg = 'Wrong email or password';
}
}
}
}
}
}
?>
<?php
include_once "new login.php";
class OpenPage extends Login
{
private $getId;
public function openpage()
{
$this->Login();
$this->getId = $this->id;
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
echo $this->id;;
}
}
$openpage = new OpenPage();
?>