Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- index
- <?php
- session_start();
- ?>
- <!DOCTYPE HTML>
- <html lang="pl">
- <head>
- <meta charset="UTF-8">
- <title>Strona</title>
- <link rel="stylesheet" type="text/css" href="style/glowny.css">
- <script type="text/javascript" src="skrypty/aktualizacja.js"> </script>
- </head>
- <body>
- <div id="pojemnik">
- <div id="naglowek">
- <img src="grafiki/baner.jpg" width="100%" height="150px">
- </div>
- <div id="pasek">
- <h2> <marquee> Strona interentowa koła fizycznego</marquee> </h2>
- </div>
- <div id="menu">
- <?php
- if(isset($_SESSION['blad'])) echo $_SESSION['blad'];
- ?>
- <?php
- if (isset($_SESSION['zalogowany']) && $_SESSION['zalogowany'])
- echo '<form method="POST" action="wyloguj.php">
- <center><button type="submit" value="WYLOGUJ" name="wylogow">WYLOGUJ</button></center>
- </form>';
- else
- echo '<form action="zaloguj.php" method="post">
- Login: <br /> <input type="text" name="login" /> <br />
- Hasło: <br /> <input type="password" name="haslo" /> <br /><br />
- <input type="submit" value="Zaloguj się" />
- </form>';
- ?>
- </div>
- <div id="tresc">
- <img style="position: absolute; top:250px; left:900px; "src="grafiki/zdjecie.jpg" id="zdjecie1" height="400px" width="400px">
- </div>
- <div id="stopka">
- <h2> Ostatnia aktualizacja strony : <script> czas(); </script> </h2>
- </div>
- </div>
- </body>
- </html>
- zaloguj
- <?php
- session_start();
- if ((!isset($_POST['login'])) || (!isset($_POST['haslo'])))
- {
- header('Location: index.php');
- exit();
- }
- require_once "connect.php";
- $polaczenie = @new mysqli($host, $db_user, $db_password, $db_name);
- if ($polaczenie->connect_errno!=0)
- {
- echo "Error: ".$polaczenie->connect_errno;
- }
- else
- {
- $login = $_POST['login'];
- $haslo = $_POST['haslo'];
- $login = htmlentities($login, ENT_QUOTES, "UTF-8");
- $haslo = htmlentities($haslo, ENT_QUOTES, "UTF-8");
- if ($rezultat = @$polaczenie->query(
- sprintf("SELECT * FROM account WHERE Login='%s' AND Password='%s'",
- mysqli_real_escape_string($polaczenie,$login),
- mysqli_real_escape_string($polaczenie,$haslo))))
- {
- $ilu_userow = $rezultat->num_rows;
- if($ilu_userow>0)
- {
- $_SESSION['zalogowany'] = true;
- $wiersz = $rezultat->fetch_assoc();
- $_SESSION['id'] = $wiersz['id'];
- unset($_SESSION['blad']);
- $rezultat->free_result();
- header('Location: index.php');
- } else {
- $_SESSION['blad'] = '<span style="color:red">Nieprawidłowy login lub hasło!</span>';
- header('Location: index.php');
- }
- }
- $polaczenie->close();
- }
- ?>
- connect
- <?php
- $host = "localhost";
- $db_user = "root";
- $db_password = "";
- $db_name = "przepisowo";
- ?>
- wyloguj
- <?php
- session_start();
- $_SESSION['zalogowany'] = false;
- header('Location: index.php');
- ?>
- logout
- <?php
- session_start();
- session_unset();
- header('Location: index.php');
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement