همین الان یه سایت وردپرس آپلود کردم. کاملا درست کار میکنه.
احتمالا مشکل از کد منه... ولی من مشکلی نمی بینم!
کد:
<?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
}
}
}
?>