Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> __construct i blad brakujacego argumentu
spandor
post
Post #1





Grupa: Zarejestrowani
Postów: 99
Pomógł: 0
Dołączył: 2.03.2004

Ostrzeżenie: (0%)
-----


witam,

mam taki konstruktor jak ponizej, dlaczego wyzuca mi blad:
Missing argument 1 for authentication::__construct(),
Missing argument 2 for authentication::__construct(),

  1. <?php
  2. class authentication {
  3.    var $mysql = 'dsadsad';
  4.    var $session;
  5.  
  6.    function __construct($mysql, $session) {
  7.       $this->mysql     = $mysql;
  8.       $this->session   = $session;
  9.    }
  10.  
  11.    function authentication() {
  12.    global $smarty, $l;
  13.        $session_var['authentication']  = $this->session->_read('authentication');
  14.        if (empty($session_var)) {
  15.            $smarty->display('inc_login.tpl');
  16.          
  17.            if (!empty($_POST) and empty($_POST['user_username'])) {
  18.                $smarty->assign('error', $l['username_field_left_empty']);
  19.            } else if (!empty($_POST) and empty($_POST['user_password'])) {
  20.                $smarty->assign('error', $l['password_field_left_empty']);
  21.            } else if (!empty($_POST)) {
  22.                $result = $this->mysql->query_one_result("SELECT COUNT(*) FROM `user`
  23.                                                          WHERE `login`='".$this->mysql->escape($_POST['AuthenticationLogin'])."'
  24.                                                          AND `password`='".$this->mysql->escape($this->secure($_POST['AuthenticationPassword']))."';");
  25.                if (empty($result)) {
  26.                    $smarty->assign('error', $l['username_or_password_is_incorrect']);
  27.                } else {
  28.                    $result = $this->mysql->query_one_result("SELECT `user_id` FROM `user`
  29.                                                              WHERE `login`='".$this->mysql->escape($_POST['AuthenticationLogin'])."'
  30.                                                              AND `password`='".$this->mysql->escape($this->secure($_POST['AuthenticationPassword']))."';");
  31.                  
  32.                    $this->session->_write('authentication', $result);
  33.                  
  34.                    header('Location: index.php');
  35.                }
  36.            }
  37.            exit;
  38.        } else if (!empty($session_var['authentication']) and isset($_GET['logout'])) {
  39.            $this->logout();          
  40.        }
  41.    }
  42.  
  43.    function check_authentication() {
  44.        $session_var['authentication']  = $this->session->_read('authentication');
  45.        return (!empty($session_var['authentication'])) ? $session_var['authentication'] : FALSE;
  46.    }
  47.  
  48.    function logout() {
  49.        $this->session->_destroy('authentication');
  50.        header('Location: '.BASE_URL);
  51.    }
  52.  
  53.    // Used so that it would be easier later to change encode method.
  54.    function secure($data) {
  55.        return md5($data);
  56.    }
  57. }
  58. ?>


Ten post edytował spandor 16.02.2009, 00:56:01
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 19:29