Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <?php
- if(isset($_POST['username']) && isset($_POST['psw'])){
- $username = $_POST['username'];
- $psw = $_POST['psw'];
- $con = mysqli_connect('localhost','root','','cms');
- $sql = "select imie, nazwisko, username, password from users where username='$username' and password='$psw'";
- $wynik = mysqli_query($con,$sql);
- if($wynik){
- while($wiersz = mysqli_fetch_assoc($wynik)){
- if($username == $wiersz['username'] && $psw == $wiersz['password']){
- $_SESSION['imie'] = $wiersz['imie'];
- $_SESSION['nazwisko'] = $wiersz['nazwisko'];
- $_SESSION['logged']=1;
- }
- else{
- echo "<script>alert ('Błędny login lub hasło');</script>";
- header("Location:index.php");
- }
- }
- }
- else{
- echo "Błąd połączenia z bazą danych";
- exit;
- }
- }
- if(!isset($_SESSION['logged'])){
- ?>
- <div id="login">
- <button onclick="document.getElementById('id01').style.display='block'">Zaloguj</button>
- </div>
- <div id="id01" class="modal">
- <form class="modal-content animate" action="index.php" method="post">
- <div class="modal-container">
- <span onclick="document.getElementById('id01').style.display='none'" class="close" title="Close login modal">×</span>
- <label for="username">
- <b>Użytownik</b>
- <input type="text" placeholder="Wpisz nazwę użytkownika" name="username" id="username" required>
- <br />
- </label>
- <label>
- <b>Hasło</b>
- <input type="password" placeholder="Wpisz hasło" name="psw" required>
- <br>
- </label>
- <button type="submit">Zaloguj</button>
- </div>
- <div class="modal-container" style="background-color:#f1f1f1">
- <button type="button" onclick="document.getElementById('id01').style.display='none'" class="cancelbtn">Anuluj</button>
- </div>
- </form>
- </div>
- <?php
- }
- else{
- echo "<a href=\"index.php?logout=1\"><button type='button' id='logout'>Wyloguj!</button></a>";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement