Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> System logowania
blurblade
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 15.11.2016

Ostrzeżenie: (0%)
-----


Czesc,
mam system logowania na stronie, który po zalogowaniu przenosi mnie do innego pliku .php, natomiast chcialbym, aby uzytkownik pozostawal na stronie index.php i wraz z zalogowaniem byla mozliwosc zobaczyc wiecej rzeczy na tej stronie index.php

I druga rzecz to jest, że gdy po podaniu blednego emailu(loginu) i hasla wysiwetla sie komunikat "Nieprawidłowy login lub hasło!" tak jak powinien, lecz niestety po odwiezeniu strony itd, dalej on jest ;/


INDEX.PHP
  1. ?php
  2.  
  3. session_start();
  4.  
  5. if ((isset($_SESSION['zalogowany'])) && ($_SESSION['zalogowany']==true))
  6. {header('Location: gra.php');
  7. exit();
  8. }
  9.  
  10. ?>
  11. <!DOCTYPE html>
  12. <html lang="pl">
  13. <head>
  14. <title>BLURBLADE</title>
  15. <meta charset="UTF-8"/>
  16. <meta http-equiv="X-UA-Compatibile" content="IE=edge,chrome=1"/>
  17. <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
  18. <link rel="stylesheet" type="text/css" href="index.css"/>
  19. <link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet">
  20. <link href="https://fonts.googleapis.com/css?family=Archivo+Narrow" rel="stylesheet">
  21. <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
  22. </head>
  23.  
  24. <body>
  25.  
  26. <div id="content">
  27. <?php
  28. require_once('top.php');
  29. ?>
  30. </div>
  31.  
  32.  
  33. <?php
  34.  
  35. if(isset($_SESSION['blad'])) echo $_SESSION['blad'];
  36.  
  37. ?>
  38. </body>
  39. </html>


LOGIN.PHP
  1. <?php
  2.  
  3. if((!isset($_POST['login'])) || (!isset($_POST['haslo'])))
  4. {
  5. header('Location: index.php');
  6. exit();
  7. }
  8.  
  9. require_once "connect.php";
  10.  
  11. $polaczenie = @new mysqli($host, $db_user, $db_password, $db_name);
  12.  
  13. if($polaczenie->connect_errno!=0)
  14. {
  15. echo "Error:".$polaczenie->connect_errno;
  16. }
  17. else
  18. {
  19. $login = $_POST['login'];
  20. $haslo = $_POST['haslo'];
  21.  
  22. $login = htmlentities($login, ENT_QUOTES, "UTF-8");
  23. $haslo = htmlentities($haslo, ENT_QUOTES, "UTF-8");
  24.  
  25.  
  26. if($rezultat = @$polaczenie->query(
  27. sprintf("SELECT * FROM users WHERE email = '%s' AND haslo ='%s'",
  28. mysqli_real_escape_string($polaczenie,$login),
  29. mysqli_real_escape_string($polaczenie,$haslo))))
  30.  
  31. {
  32. $ilu_userow = $rezultat->num_rows;
  33. if($ilu_userow>0)
  34. {
  35. $_SESSION['zalogowany'] = true;
  36. $wiersz = $rezultat->fetch_assoc();
  37. $_SESSION['id'] = $wiersz['id'];
  38. $_SESSION['email'] = $wiersz['email'];
  39. $_SESSION['user'] = $wiersz['user'];
  40.  
  41.  
  42. unset($_SESSION['blad']);
  43. $rezultat->close();
  44. header('Location: index.php');
  45. }
  46. else
  47. {
  48. $_SESSION['blad'] = '<span style="color:red">Nieprawidłowy login lub hasło!</span>';
  49. header('Location:index.php');
  50. }
  51. }
  52.  
  53. $polaczenie->close();
  54. }
  55.  
  56.  
  57. ?>

Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.08.2025 - 09:36