Advertisement
Guest User

Untitled

a guest
Oct 30th, 2017
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.10 KB | None | 0 0
  1.  
  2. index
  3. <?php
  4.  
  5. session_start();
  6.  
  7.  
  8.  
  9. ?>
  10.  
  11. <!DOCTYPE HTML>
  12.  
  13. <html lang="pl">
  14.  
  15. <head>
  16. <meta charset="UTF-8">
  17. <title>Strona</title>
  18. <link rel="stylesheet" type="text/css" href="style/glowny.css">
  19. <script type="text/javascript" src="skrypty/aktualizacja.js"> </script>
  20. </head>
  21.  
  22.  
  23. <body>
  24.  
  25. <div id="pojemnik">
  26.  
  27.  
  28. <div id="naglowek">
  29. <img src="grafiki/baner.jpg" width="100%" height="150px">
  30. </div>
  31. <div id="pasek">
  32. <h2> <marquee> Strona interentowa koła fizycznego</marquee> </h2>
  33. </div>
  34.  
  35. <div id="menu">
  36. <?php
  37. if(isset($_SESSION['blad'])) echo $_SESSION['blad'];
  38. ?>
  39. <?php
  40. if (isset($_SESSION['zalogowany']) && $_SESSION['zalogowany'])
  41. echo '<form method="POST" action="wyloguj.php">
  42. <center><button type="submit" value="WYLOGUJ" name="wylogow">WYLOGUJ</button></center>
  43. </form>';
  44. else
  45. echo '<form action="zaloguj.php" method="post">
  46.  
  47. Login: <br /> <input type="text" name="login" /> <br />
  48. Hasło: <br /> <input type="password" name="haslo" /> <br /><br />
  49. <input type="submit" value="Zaloguj się" />
  50.  
  51. </form>';
  52. ?>
  53.  
  54.  
  55. </div>
  56.  
  57. <div id="tresc">
  58. <img style="position: absolute; top:250px; left:900px; "src="grafiki/zdjecie.jpg" id="zdjecie1" height="400px" width="400px">
  59. </div>
  60.  
  61.  
  62. <div id="stopka">
  63.  
  64. <h2> Ostatnia aktualizacja strony : <script> czas(); </script> </h2>
  65.  
  66. </div>
  67.  
  68. </div>
  69.  
  70. </body>
  71.  
  72. </html>
  73.  
  74.  
  75.  
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.  
  86.  
  87.  
  88.  
  89. zaloguj
  90.  
  91.  
  92. <?php
  93.  
  94. session_start();
  95.  
  96. if ((!isset($_POST['login'])) || (!isset($_POST['haslo'])))
  97. {
  98. header('Location: index.php');
  99. exit();
  100. }
  101.  
  102. require_once "connect.php";
  103.  
  104. $polaczenie = @new mysqli($host, $db_user, $db_password, $db_name);
  105.  
  106. if ($polaczenie->connect_errno!=0)
  107. {
  108. echo "Error: ".$polaczenie->connect_errno;
  109. }
  110. else
  111. {
  112. $login = $_POST['login'];
  113. $haslo = $_POST['haslo'];
  114.  
  115. $login = htmlentities($login, ENT_QUOTES, "UTF-8");
  116. $haslo = htmlentities($haslo, ENT_QUOTES, "UTF-8");
  117.  
  118. if ($rezultat = @$polaczenie->query(
  119. sprintf("SELECT * FROM account WHERE Login='%s' AND Password='%s'",
  120. mysqli_real_escape_string($polaczenie,$login),
  121. mysqli_real_escape_string($polaczenie,$haslo))))
  122. {
  123. $ilu_userow = $rezultat->num_rows;
  124. if($ilu_userow>0)
  125. {
  126. $_SESSION['zalogowany'] = true;
  127.  
  128. $wiersz = $rezultat->fetch_assoc();
  129. $_SESSION['id'] = $wiersz['id'];
  130.  
  131.  
  132. unset($_SESSION['blad']);
  133. $rezultat->free_result();
  134. header('Location: index.php');
  135.  
  136. } else {
  137.  
  138. $_SESSION['blad'] = '<span style="color:red">Nieprawidłowy login lub hasło!</span>';
  139. header('Location: index.php');
  140.  
  141. }
  142.  
  143. }
  144.  
  145. $polaczenie->close();
  146. }
  147.  
  148. ?>
  149.  
  150.  
  151.  
  152.  
  153.  
  154. connect
  155.  
  156.  
  157. <?php
  158.  
  159. $host = "localhost";
  160. $db_user = "root";
  161. $db_password = "";
  162. $db_name = "przepisowo";
  163.  
  164. ?>
  165.  
  166.  
  167.  
  168.  
  169. wyloguj
  170.  
  171. <?php
  172. session_start();
  173.  
  174. $_SESSION['zalogowany'] = false;
  175. header('Location: index.php');
  176.  
  177. ?>
  178.  
  179.  
  180.  
  181. logout
  182.  
  183.  
  184. <?php
  185.  
  186. session_start();
  187.  
  188. session_unset();
  189.  
  190. header('Location: index.php');
  191.  
  192. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement