Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]logowanie jako admin
gregov0
post
Post #1





Grupa: Zarejestrowani
Postów: 58
Pomógł: 0
Dołączył: 14.01.2011
Skąd: Kalisz

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


mam taki kod
  1. <?php
  2. session_start(); // rozpoczęcie sesji
  3. ?>
  4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  5. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl" lang="pl">
  6. <head>
  7.  
  8. <meta name="Description" content="Witryna e-learningowa" />
  9. <meta name="Keywords" content="," />
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8; "/>
  11. <meta http-equiv="content-language" content="pl">
  12. <meta name="Distribution" content="Global" />
  13. <meta name="Author" content="grzegorzw" />
  14. <meta name="Robots" content="index,follow" />
  15. <script type="text/javascript" language="JavaScript" src="overlib.js"></script>
  16. <link rel="stylesheet" href="images/style.css" type="text/css" />
  17.  
  18. <title>logowanie</title>
  19. <!--<script language="javascript" type="text/javascript">
  20. function popup()
  21. {
  22. popupwindow=window.open('szkolenie/kurs.htm', 'Mójkurs','height=600,width=800,menubar=no,scrollbars=no,resizable=no,status=no,location=no');
  23. popupwindow.moveTo(0,0);
  24. }
  25. </script>-->
  26. </head>
  27.  
  28. <body>
  29. <?php include('header.php'); ?>
  30. <div id="glokno">
  31.  
  32. <a name="stronainfo"></a>
  33. <h1>Zaloguj się</h1>
  34. <div class="content">
  35.  
  36. <?php
  37.  
  38.  
  39. if (!isset($_SESSION['login'])) { // dostęp dla niezalogowanego użytkownika
  40.  
  41. if ($_POST['wyslane']) {
  42.  
  43. include 'db.php';
  44. $tabela = 'uzytkownik';
  45.  
  46. $login = $_POST["login"];
  47. $haslo = $_POST["haslo"];
  48.  
  49. $haslo = md5($haslo);
  50.  
  51. // użytkownik się loguje
  52. $wynik=mysql_query("SELECT * FROM $tabela WHERE login='$login' and haslo='$haslo'");
  53.  
  54. if (mysql_num_rows($wynik) == 1) {
  55.  
  56. $informacja = mysql_fetch_array($wynik);
  57. $_SESSION["login"] = $informacja["login"];
  58. header('Location: index.php ');
  59. } else {
  60. echo '<p>Zostały wprowadzone nieprawidłowe dane</p>';
  61. }
  62. mysql_close($polaczenie);
  63. }
  64.  
  65. // tworzenie formularza HTML
  66. echo <<< KONIEC
  67.  
  68.   <form class="form" action="logowanie.php" method="post">
  69.   <input type="hidden" name="wyslane" value="TRUE" />
  70.  
  71.   <p>
  72. <div class="label"><label for="login">Login</label></div>
  73. <input type="text" name="login" id="login" />
  74. </p>
  75.  
  76. <p>
  77. <div class="label"><label for="haslo">Hasło</label></div>
  78. <input type="password" name="haslo" id="haslo" />
  79. </p>
  80.  
  81.   <p class="submit2">
  82.   <input type="submit" value="Zaloguj mnie" />
  83.   </p>
  84.  
  85. <p class="przypomnij">
  86. <a href="przypomnienie.php">Nie pamiętasz hasła?</a>
  87. </p>
  88.  
  89.   </form>
  90. KONIEC;
  91.  
  92. } else {
  93. header('Location: index.php');
  94. }
  95.  
  96. if ($_GET["wylogowanie"] == "tak") {
  97. // niszczenie sesji
  98. header('Location: index.php');
  99. }
  100.  
  101. ?>
  102.  
  103. </div>
  104. </div>
  105. <?php include("footer.php");?>

Chciałbym żeby po wpisaniu jako loginu np słowa admin otwierała sie inna stronka niż dla pozostałych użytkowników. Ma ktoś jakiś pomysł?
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: 22.08.2025 - 05:36