Ten kod powinien w wypadku wpisania złego hasła wyświetlić nad formularzem "Podano złe dane!!!" Ale nie wyświetla absolutnie nic. Przy podaniu dobrego loginu i hasła jedynie loguje. Co jest nie tak? (IMG:
http://forum.php.pl/style_emoticons/default/sad.gif)
<?php
if(empty($_SESSION["zalogowany"]))$_SESSION["zalogowany"]=0;
require "connection.php";
connection();
function ShowLogin($komunikat=""){
if($_SESSION["zalogowany"] == 0)
{
echo "<form action='index.php' method=post>"; echo "Login: <input type=text name=login><br>"; echo "Hasło: <input type=text name=haslo><br>"; echo "<input type=submit value='Zaloguj!'>"; echo "Jeśli nie jesteś zarejestrowany, <a href='index.php?site=register'>zarejestruj się tutaj.</a>"; }
else
{
$id_gracza = $_SESSION["zalogowany"];
$imie = mysql_query("SELECT name from `char` where ID LIKE '$id_gracza'"); echo "Zalogowany jako $id_gracza"; echo "<a href='index.php?wyloguj=tak'>wyloguj się</a>"; }
}
?>
<html>
<head>
<title>Olimpus MMORPG</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<link rel="Stylesheet" type="text/css" href="style.css" />
</head>
<body>
<center>
<div id="top">
<div id="NAGLOWEK">
<img src='left.jpg'><img src='banner.jpg'><img src='right.jpg'>
</div>
<div id="top2">
<div id="LOGIN">
<?
if($_GET["wyloguj"]=="tak")
{
$_SESSION["zalogowany"]=0;echo "Zostałeś wylogowany z serwisu";
}
if(!empty($_POST["login"]) && !empty($_POST["haslo"])) {
$loginn = $_POST['login'];
$hasloo = $_POST['haslo'];
if(mysql_query("SELECT * from `char` where name = '$loginn' AND pass = '$hasloo2'") == TRUE) {
echo "Zalogowano poprawnie. <a href='index.php'>PrzejdĽ na stronę główną</a>";
$wynik = mysql_query("SELECT * FROM `char` WHERE name = '$loginn'");
{
$_SESSION["zalogowany"]=$pola["ID"];
}
}
else ShowLogin("Podano złe dane!!!");
}
else ShowLogin();
?>
</div>
<div id="MENU">
<a href='index.php'>-Strona główna</a>
</div>
<div id="TRESC">
<pre><?php
if($_GET[site] != '')
{
include(''.$_GET[site].'.htm');
}
else
{
header("location: index.php?site=main"); }
?>
</div>
</div>
<div id="STOPKA">
<?
include('Stopka.txt');
?>
</div>
</div>
</center>
</body>
</html>