Skip to content

Commit

Permalink
logowanie 2
Browse files Browse the repository at this point in the history
  • Loading branch information
krisskiemel committed Mar 25, 2022
1 parent 18e2066 commit 7373862
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
1 change: 0 additions & 1 deletion klienci.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@
?>
</div>
</div>

</body>

</html>
8 changes: 8 additions & 0 deletions logowanie.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
session_start();
if (isset($_COOKIE['kolory'])) {
$kolory = $_COOKIE['kolory'];
} else {
Expand Down Expand Up @@ -43,11 +44,18 @@
$result_log = $conn->query($sql_log);
if ($row_log = $result_log->fetch_assoc()) {
if ($password == $row_log['password']) {
header('Refresh:3 ; URL=index.php');
$_SESSION['user'] = $login;
$_SESSION['pass'] = $password;
echo "<p>Zalogowano</p>";
} else {
unset($_SESSION["user"]);
unset($_SESSION["pass"]);
echo "<p>Nieprawidłowe hasło: $password " . $row_log['password'] . "</p>";
}
} else {
unset($_SESSION["user"]);
unset($_SESSION["pass"]);
echo "<p>Nieprawidłowy login</p>";
}
}
Expand Down
26 changes: 22 additions & 4 deletions menu.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
<?php
session_start();
if(isset($_SESSION['user']) && isset($_SESSION['pass'])) {
$zalogowany = true;
} else {
$zalogowany = false;
}
?>
<nav class="navbar navbar-expand-sm navbar-dark bg-<?php echo $kolory?>">
<div class="container-fluid">
<a class="navbar-brand" href="index.php">
Expand All @@ -21,10 +29,20 @@
<a class="nav-link" href="ustawienia.php">Ustawienia</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a class="nav-link" href="rejestracja.php"></span> Zarejestruj się</a></li>
<li><a class="nav-link" href="logowanie.php"></span> Zaloguj</a></li>
</ul>
<?php
if (!$zalogowany) {?>
<ul class="nav navbar-nav navbar-right">
<li><a class="nav-link" href="rejestracja.php"></span> Zarejestruj się</a></li>
<li><a class="nav-link" href="logowanie.php"></span> Zaloguj</a></li>
</ul>
<?php
} else {?>
<ul class="nav navbar-nav navbar-right">
<li>Zalogowany</li>
</ul>
<?php
}
?>
</div>
</div>
</nav>

0 comments on commit 7373862

Please sign in to comment.