json всегда возвращает первый id
<?php
require 'init.php';
session_start();
if (!isset($_SESSION['email'])) {
$email = isset($_POST['email']) ? $_POST['email'] : '';
$password = isset($_POST['password']) ? $_POST['password'] : '';
$email = htmlspecialchars($email);
$password = htmlspecialchars($password);
if (isset($_POST['submit'])) {
if (!empty($email) && !empty($password)) {
$firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);
$json = $json = '{
"Id" : {
"Name" : "Karen",
"email" : "karenshahmuradyan@gmail.com",
"password" : "123456"
},
"ID2" : {
"Name" : "Anush",
"email" : "duduk1992@mail.ru",
"password" : "1992120"
}
}';
$json_ary = json_decode($json, true);
foreach ($json_ary as $id => $val) {
if ('"' . $email . '"' == $firebase->get(DEFAULT_PATH . "/ARCusers/$id/email") && '"' . $password . '"' == $firebase->get(DEFAULT_PATH . "/ARCusers/$id/password")) {
echo "true";
} else {
echo "false";
}
}
}
}
}
?>
<b><?php
if (isset($_SESSION['email'])) {
echo 'You are already logged in.';
} else {
echo 'Log in:';
?></b>
<br>
<br>
<form action="newlogin.php" method="post">
Email address:
<br>
<input type="text" name="email" maxlength="128">
<br>
<br>
Password:
<br>
<input type="password" name="password" maxlength="128">
<br>
<br>
<input type="submit" name="submit" value="Submit">
</form>
<?php } ?>