
Tak wygląda mój kod:
login.php
- Kod: Zaznacz wszystko
<?php
session_start();
if(isset($_SESSION['login'])){
echo "<p style='float: left; margin-left: 10px; color: #333333; font-weight:bold;'>Witaj $_SESSION[login]</p>";
}elseif(!isset($_POST['nazwa']) or !isset($_POST['haslo'])){
?>
<form method="POST" action="">
<label class="foo">Login:</label>
<input type="text" name="nazwa" id="nazwa" size="7"/>
<label class="foo">Hasło:</label>
<input type="password" name="haslo" id="haslo" size="7"/>
<input type="submit" value="Zaloguj"/>
</form>
<?php
}else{
$dir=md5($_POST['nazwa']);
if(file_exists("db/$dir.php")){
include("db/$dir.php");
}
if(!isset($user[$_POST['nazwa']]) or $user[$_POST['nazwa']]['password']!=md5($_POST['haslo'])){
echo '<meta http-equiv="refresh" content="4;url=http://www.history.is.net.pl/"><p style="text-align:center; background-color:#FF99CC; width: 320px; color: #D31141; font-weight: bold">Niepoprawna nazwa użytkownika lub hasło.</p>';
}else{
$_SESSION['login']=$_POST['nazwa'];
echo "<p style='float: left; margin-left: 10px; color: #333333; font-weight:bold;'>Witaj $_SESSION[login]</p>";
}
}
?>