index.php
<?php include ("/include/logowanie.include.php"); ?> <div style="margin: 0 auto; text-align: center; "> Podaj autora lub Tytuł książki: <br /> <form name="wyszukiwarka" method="post" action="index.php"> <input name="szukanehaslo" type="text" size="30" maxlength="40"> <input type="submit" value="Szukaj"> </form> <?php include ("/include/logowanie.do.bazy.php"); polaczenie(); $szukanehaslo = $_POST["szukanehaslo"]; { if ($_POST["szukanehaslo"] != NULL) { $query = " SELECT * from tabelabiblioteka WHERE autor LIKE '%$szukanehaslo%' OR nazwa LIKE '%$szukanehaslo%' "; } else { { } else { "<table bgcolor=#EEEEEE border=1 align=center><tr> <th>LP</th> <th>ID</th> <th>Nazwa</th> <th>Autor</th> <th>Wydawnictwo</th> <th>Rok wyd.</th> <th>Oprawa</th> <th>Dostepność</th> </tr>"; { if ($row['oprawa'] == 1) $row['oprawa'] = "twarda"; else $row['oprawa'] = "miękka"; if ($row['akt_stan'] ==1) $row['akt_stan'] = "dostępna"; else $row['akt_stan'] = "niedostępna"; $usun_id = $row['id']; $edit_id = $row['id']; } } } } zamknij_baze(); ?> </div>
logowanie.include.php
<? { $_SESSION['initiate'] = 1; } ?> <html> <title>Cwiczenia z baza danych dla infotechu</title> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> </head> <body bgcolor="#EEEEEE"> <div style="text-align:center; background-color: #dbdbdb; height: 120px; width: 400px;"> <? { $_SESSION["zalogowany"] = 0; $_SESSION["admin"] = 0; } ?> <?php { { if ($_SESSION['zalogowany'] == 0 && $_SESSION["admin"]==0) { $login = filter_var($_POST['login'], FILTER_SANITIZE_STRING); $haslo = filter_var($_POST['haslo'], FILTER_SANITIZE_STRING); } if ($login == "Matys" && $haslo == "abc" || $_SESSION["zalogowany"] == 1) { if ($_SESSION["zalogowany"] == 0) $_SESSION["login"] = $login; $_SESSION["zalogowany"] = 1; } else if($login == "admin" && $haslo == "admin" || $_SESSION["admin"] == 1) { if ($_SESSION["admin"] == 0) $_SESSION["login"] = $login; $_SESSION["admin"] = 1; } } } if ($_SESSION["zalogowany"] == 0 && $_SESSION["admin"] == 0) { ?> <br />LOGOWANIE: <form name="panellogowania" method="post" action="index.php"> <input type="text" name="login"/> <input type="password" name="haslo"/> <input type="submit" value="Zaloguj"/> </form> <? } if (($_SESSION["zalogowany"]==0) && ($_SESSION["admin"]==0)) { } ?> </div> </body>