<?php
session_start();
class MyClass
{
    public function checkMe()
    {
        if($_SESSION['auth'] == 'yes')
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    
    public function login()
    {
        if($this->checkMe() === false)
        {
            if(isset($_POST['login']))
            {
                $username = $_POST['username'];
                $password = $_POST['password'];
                $sql = "SELECT * FROM admin WHERE username = '$username' AND password=SHA1('$password')";
                //query Database
                $db = new db;
                $result = $db->queryAll($sql);
                if(count($result) == 1)
                {
                    $_SESSION['auth'] = 'yes';
                    $login = false;
                }
                else
                {
                    $error = 'نام كاربرى يا رمز عبور اشتباه مي باشد.';
                }
            }
            if($login === true)
            {
                //render login page
                $this->registry->template->error = $error;
                $this->registry->template->render('admin/login');
            }
            else
            {
                //function index
                $this->index();
            }
            
        }
        elseif($this->checkMe() === true)
        {
            //function index
            $this->index();
        }
    }
    
    public function index()
    {
        if($this->checkMe() === true)
        {
            //render index page
            $this->registry->template->message= 'خوش آمدید';
            $this->registry->template->render('admin/index');
        }
    }
    
    public function sampleFunction()
    {
        if($this->checkMe() === true)
        {
            //do sth else
        }
    }
}
?> ببینید چند جا چک کردن که فلان مقدار true هست... بگذریم) شما یه لطفی بکن و چند خط کد زیر رو بریز داخل فایلی به اسم testme.php و بعد اجراش کن (از کد خودتون استفاده کردم)
 ببینید چند جا چک کردن که فلان مقدار true هست... بگذریم) شما یه لطفی بکن و چند خط کد زیر رو بریز داخل فایلی به اسم testme.php و بعد اجراش کن (از کد خودتون استفاده کردم)<?php
session_start();
class MyClass
{
    public function checkMe()
    {
        if($_SESSION['auth'] == 'yes')
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    
    public function login()
    {
        if($this->checkMe() === false)
        {
            if(1)
            {
             $_SESSION['auth'] = 'yes';
             
             echo 'logged in! click <a href="testme.php">here</a> ';
            }
            /*if($login === true)
            {
                //render login page
                echo 'bad login!';
            }*/
            else
            {
                //function index
                $this->index();
            }
            
        }
        elseif($this->checkMe() === true)
        {
            //function index
            $this->index();
        }
    }
    
    public function index()
    {
        if($this->checkMe() === true)
        {
            //render index page
            echo 'welcome';
        }
    }
    
    public function sampleFunction()
    {
        if($this->checkMe() === true)
        {
            //do sth else
        }
    }
}
$b = new MyClass();
$b->login();
?> )
)
 کارم رو راه بندازم)
 کارم رو راه بندازم) قضیه رو پیگیری کنم، دقت کردین شما هیچ اطلاعاتی به ما ندادین؟!!)
 قضیه رو پیگیری کنم، دقت کردین شما هیچ اطلاعاتی به ما ندادین؟!!)









