Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][MySQL] Rangi + dostęp
Deotho
post
Post #1





Grupa: Zarejestrowani
Postów: 79
Pomógł: 0
Dołączył: 2.05.2012
Skąd: Hogwart

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


Witam,
chciałbym zrobić system rang + dostępu.

Administrator - Panel administratora, panel moderatora - rank = 2
Moderator - Panel moderatora, brak dostępu do panelu administratora - rank = 1
Użytkownik - brak dostępu do PA i PM - rank = 0

Jak mogę coś takiego stworzyć?
Prosiłbym, aby ktoś mnie naprowadził, bo nie wiem jak zacząć.

Ten post edytował Deotho 14.05.2012, 08:49:55
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
Deotho
post
Post #2





Grupa: Zarejestrowani
Postów: 79
Pomógł: 0
Dołączył: 2.05.2012
Skąd: Hogwart

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


login.php
  1. <?php
  2. include ("config/db.php");
  3. IF(isset($_SESSION['login'])) {header('Location: index.php'); }
  4.  
  5. if ($_POST['login']) {
  6. $login = addslashes($_POST['login']);
  7. $haslo = md5($_POST['haslo']);
  8.  
  9. $sql = "SELECT * FROM users WHERE login='$login'";
  10. $wykonaj = mysql_query($sql) or die(mysql_error());
  11. $dane = mysql_fetch_assoc($wykonaj);
  12.  
  13. if($login == $dane['login'] && $haslo == $dane['haslo']) {
  14. $_SESSION["user"] = $dane['rank'];
  15. }
  16.  
  17.  
  18. $db = mysql_query("SELECT * FROM users WHERE login='".$login."' and haslo='".$haslo."'");
  19.  
  20. if (mysql_num_rows($db) == 1) {
  21. $info = mysql_fetch_array($db);
  22. if ($info['active'] == 0) {
  23. header('Location: index.php?active=0');
  24. }
  25. if ($info['active'] == 1) {
  26. $_SESSION["login"] = $info["login"];
  27. header('Location: index.php ');
  28. }
  29. } else {
  30. echo '<html><head><meta content="text/html; charset=utf-8" http-equiv="Content-Type" /></head><body><span class="blad">Podane dane są nieprawidłowe!</span><br><a href="index.php">Strona Główna</a></body></html>';
  31. }
  32. }
  33.  
  34.  
  35. if ($_GET["wylogowanie"] == "tak") {
  36. header('Location: index.php');
  37. }
  38.  
  39. ?>


admin.php
  1. <?php
  2. include('config/db.php');
  3. include('templates/header.php');
  4. if ($_SESSION["user"] == 1) {
  5. echo ' Witaj w panelu administratora. ';
  6. } else {
  7. echo '<center>Nie masz dostępu do panelu administratora.</center>';
  8. }
  9. ?>
  10.  
  11.  
  12.  
  13. <?php include('templates/footer.php'); ?>


Nadałem sobie uprawnienia = o czyli użytkownik i powinno wyświetlać, że nie mam dostępu do panelu administratora - no i wyświetla, ale jak nadam sobie uprawnienia = 1 to jestem adminem i powinno wyświetlać Witaj w panelu, a wyświetla, że nie mam uprawnień. Coś źle zrobiłem ?

(IMG:style_emoticons/default/questionmark.gif)
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: 29.12.2025 - 20:37