skus toto:
Kód:
<h1>prosim Vas, prihlaste sa ...</h1>
<form method="POST" action="">
meno: <input type='text' name='meno'> <br>
heslo: <input type='text' name='heslo'> <br>
<input type='submit' name='submit' value='Prihlasit'> <br>
</form>
<?php
session_start();
$meno=$_POST[meno];
$heslo=$_POST[heslo];
$f=fopen("data/users.php","r");
fgets($f); // PHP riadok
while (!feof($f)) // cykluje zoznam s meno|heslo od druheho riadku az dole ... mozes to dat kludne aj do *.txt alebo mysql
{
$riadok = trim(fgets($f));
$zaznam=explode("|",$riadok);
if ($riadok<>"")
{
if ($meno==$zaznam[0] and $heslo==$zaznam[1] and $meno<>"")
{
$_SESSION[login]=$meno;
$_SESSION[sec]=md5("123%&&zxcsY$meno");
break;
}
}
}
fclose($f);
$sec2=md5("123%&&zxcsY$_SESSION[login]");
if ($_SESSION[sec]==$sec2 ) header("location: index.php"); // prehodi ta na titulnu stranku
else echo "zmen meno alebo heslo ... ";
?>