K
K
kuzyairon2020-05-31 15:34:04
PHP
kuzyairon, 2020-05-31 15:34:04

Why are the conditions not met?

The point is that authorization occurs on the login.php page and then a redirect is made to the Approved page upon successful authorization.

login.php page code

if ($oneday) {
        if (password_verify($data['login'], $oneday->password))
            $SESSION['logged_user'] = $oneday;
        $active = R::dispense('activen');
        $active->token = $hashone;
        $active->join_date = $date;
        $active->expire = $date_expire_oneday;
        $active->login = $data['login'];

        $active->token = $hashone;

        R::store($active);

        R::exec("DELETE FROM oneday WHERE login = ?", [$data]);
        if ($oneday == false) {


            session_start();
            $_SESSION ['reason'] = R::getCell('SELECT `token` FROM activen WHERE `login` = ? LIMIT 1', [$data]);


            header('Location: http://localhost/approved.php');
        }


    }
    if ($sevendays) {
        if (password_verify($data['login'], $sevendays->password))
            $SESSION['logged_user'] = $sevendays;

        $activeseven = R::dispense('activen');
        $activeseven->token = $sevendays;
        $activeseven->join_date = $date;
        $activeseven->expire = $date_expire_sevendays;
        $activeseven->login = $data['login'];

        $activeseven->token = $hashseven;
        R::store($activeseven);

        R::exec("DELETE FROM sevendays WHERE login = ?", [$data]);

        header('Location: http://localhost/approved.php');

    }
    if ($sevendays == false) {



        $_SESSION ['sevendays'] = R::getCell('SELECT `token` FROM activen WHERE `login` = ? LIMIT 1', [$data]);


        header('Location: http://localhost/approved.php');
    }


And here is the approved.php page code

$errors = array();

session_start();

$activesevendouble = $_SESSION['reason'];
$activesevendays = $_SESSION['sevendays'];

if ($activesevendouble) {

    echo '<div style="color: green;">Ну все oneday </div>';
    $url = "http://example.com/activate.php?token=$activesevendouble";
     echo $url;

    if ($activesevendouble == false) {

        $errors[] = 'no akk';
    }
}
elseif ($activesevendays) {
    echo '<div style="color: green;">Ну все SEVENDAYs </div>';
    $urll = "http://example.com/activate.php?token=$activesevendays";
    echo $urll;

    if ($activesevendays == false) {

        $errors[] = 'no akk';

    }


for some reason, it displays the first condition for me, that is, the ONEDAY condition, but does not display the next condition and does not pull up the values ​​for SEVENDAYS, if I authorize the key from the SEVENDAYS table, only ONEDAY
has already broken my head, I don’t understand what and how to do
I tearfully ask for help click on this error

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolay Panaitov, 2020-05-31
@kuzyairon

Maybe in login.php before
if ($oneday) {
you need
session_start();
$oneday = isset( $_SESSION['oneday'] ) ? $_SESSION['oneday'] : false;
$sevendays = isset( $_SESSION['sevendays'] ) ? $_SESSION['sevendays'] : false;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question