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
?php
session_start();
if ((isset($_SESSION['zalogowany'])) && ($_SESSION['zalogowany']==true))
{header('Location: gra.php');
exit();
}
?>
<!DOCTYPE html>
<html lang="pl">
<head>
<title>BLURBLADE</title>
<meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatibile" content="IE=edge,chrome=1"/>
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<link rel="stylesheet" type="text/css" href="index.css"/>
<link href="https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Archivo+Narrow" rel="stylesheet">
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
</head>
<body>
<div id="content">
<?php
require_once('top.php');
?>
</div>
<?php
if(isset($_SESSION['blad'])) echo $_SESSION['blad'];
?>
</body>
</html>
LOGIN.PHP
<?php
if((!isset($_POST['login'])) || (!isset($_POST['haslo']))) {
header('Location: index.php'); }
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'];
if($rezultat = @$polaczenie->query(
sprintf("SELECT * FROM users WHERE email = '%s' AND haslo ='%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'];
$_SESSION['email'] = $wiersz['email'];
$_SESSION['user'] = $wiersz['user'];
unset($_SESSION['blad']); $rezultat->close();
header('Location: index.php'); }
else
{
$_SESSION['blad'] = '<span style="color:red">Nieprawidłowy login lub hasło!</span>';
}
}
$polaczenie->close();
}
?>