K
K
Kar922017-08-03 16:35:12
PHP
Kar92, 2017-08-03 16:35:12

I can't pass the id from the Login class to the LicenseKey, the problem is in the Login() function, "help" please?

Login

<?php

class Login
{

    protected $id;

    public function Login()
    {

        include_once 'init.php';
        if (!isset($_SESSION)) {
            session_start();
        }

        if (!isset($_SESSION['email'])) {

            $email = isset($_POST['email']) ? $_POST['email'] : '';
            $password = isset($_POST['password']) ? $_POST['password'] : '';

            $email = htmlspecialchars($email);
            $password = htmlspecialchars($password);

            $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);

            $json = $firebase->get(DEFAULT_PATH . "/ARCusers/", array('activation' => '"true"'));


            $error = false;
            $conn = false;

            if (isset($_POST['submit'])) {

                if (!empty($email) && !empty($password)) {

                    //check if it matches


                    /*$email = '"' . $email . '"';
                    $password = '"' . $password . '"';*/

                    $json_ary = json_decode($json, true);
                    foreach ($json_ary as $this->id => $val) {

                        if ($email == $firebase->get(DEFAULT_PATH . "/ARCusers/$this->id/email") && $password == $firebase->get(DEFAULT_PATH . "/ARCusers/$this->id/password")) {
                            $activation = $firebase->get(DEFAULT_PATH . "ARCusers/$this->id/activation");
                            if ($activation == 'true') {
                                $conn = true;


                            } else {
                                echo "<br>";
                                echo "<br>";
                                echo "Verify your email";
                                echo "<br>";
                            }

                        }
                    }


                    if ($conn == true) {
                        $error = false;
                    } else {
                        $error = true;
                    }

                    if ($error) {
                        echo "Error in email or/and password.";
                    }

                    if (!$error) {
                        //login
                        $_SESSION['email'] = $email;
                        echo "Logged in.";
                        header("Location: welcome.php");
                    }
                } else {
                    echo "Fill in all the details.";
                }

            }

        }



    }

}

license key
<?php

include_once "Login.php";

if (!isset($_SESSION)) {
    session_start();
}

class LicenseKey extends Login
{
    private $getId;


    public function LicenseKey()
    {

        $this->getId = $this->id;


        echo $this->getId;

         $firebase = new \Firebase\FirebaseLib(DEFAULT_URL, DEFAULT_TOKEN);

         $license_key = $firebase->get(DEFAULT_PATH . "/ARCusers/$this->getId/License/license key");
 //        $license_key_activation = $firebase->get(DEFAULT_PATH . "/ARCusers/$this->getId/License/license key activation ");
         if (isset($_GET['LicenseKey'])) {

             if ($license_key == '"' . $_GET['addlicensekey'] . '"') {

                 $firebase->set(DEFAULT_PATH . "/ARCusers/$this->getId/License/license key activation", true);

             } else {
//                 echo "false";
                 echo $this->getId;

             }
         }

    }
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
metnee, 2017-08-04
@metnee

$id is passed, just empty.
Try giving it some value, for example:

class Login
{
    protected $id = 123;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question