Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> Początki programowanie OOP, Przedstawienie kodu napisanego w oop php
Michal_PB1
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 19.03.2013

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


Jestem nowy na tym forum więc witam wszystkich.

Teraz do sedna postanowiłem rozpocząć przygodę z programowaniem obiektowym i mam pytanie czy ten kod poniżej na sens programowania obiektowego ? Proszę o wyrozumiałość to początki, ale uwagi mile widziane.
  1. class User
  2. {
  3. private $mysql;
  4. private $host = "localhost";
  5. private $uzytkownik = "user";
  6. private $baza = "baza";
  7. private $haslo = "haslo";
  8. private $prefiks = "prefiks_";
  9.  
  10. function __construct() {
  11.  
  12. $this -> spr_stan();
  13. $this -> mysql = new mysqli ($this -> host, $this -> user, $this -> pass, $this -> db);
  14.  
  15. }
  16.  
  17. function __set ($nazwa, $wartosc) {
  18. $this -> $nazwa = $wartosc;
  19. }
  20.  
  21. function __get ($nazwa) {
  22. return $this -> $nazwa;
  23. }
  24.  
  25. function zaloguj($login, $haslo) {
  26.  
  27. $sql = "SELECT * FROM ".$this -> prefiks."account WHERE login = $login AND password = $haslo ;";
  28. $sqlQry = $this -> mysql -> query($sql);
  29. $ile = $sqlQry -> num_rows;
  30. if ($ile == '1') $_SESSION['stan'] = '1';;
  31.  
  32. }
  33.  
  34. function wyloguj() {
  35.  
  36. $_SESSION['stan'] = '0';
  37. header('Location: index.php');
  38.  
  39. }
  40.  
  41. function zmien_haslo($email, $haslo) {
  42.  
  43. }
  44.  
  45. function spr_stan() {
  46.  
  47. if($_SESSION['stan'] == '1')
  48. echo '<script>powiadomienie(\'Zalogowano\', \'accept\');</script>';
  49. else
  50. {
  51.  
  52. echo '<script>powiadomienie("Aby przeglądać Panel Admina musisz się <button onClick=\"show_login();\">", "information");</script>';
  53. }
  54.  
  55. }
  56.  
  57. }
Go to the top of the page
+Quote Post

Posty w temacie


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

 



RSS Aktualny czas: 21.08.2025 - 10:46