Witam. Napisałem skrypt logowania. Może ktoś mi powiedzieć czy skrypt jest bezpieczny? Czytałem o Session Poisoning, Session fixation, Session injection i sql injection i wprowadziłem małe zmiany.
if($_POST["send"] == 1) {
if(!empty($_POST["login"]) && !empty($_POST["pass"])){
if(!preg_match('/^[0-9a-zA-Z]{1,}$/', $_POST['login']) && !preg_match('/^[0-9a-zA-Z]{1,}$/', $_POST['pass'])) { $error = "Znaki które wpisałeś są niebezpieczne";
} else {
$error = "Zły login lub hasło";
}
}
}
else {
$error = "Nie wpisałeś loginu lub hasła";
}
$_SESSION['login'] = $login['user'];
}
}
if($_SESSION['login']) {
include "main.php";
}
else {
echo "<div id='logowanie'>"; echo "<form method='post' action='index.php'>"; echo "<input type='text' maxlength='16' name='login'><br>"; echo "<input type='password' maxlength='32' name='pass'><br>"; echo "<input type='hidden' value='1' name='send'>"; echo "<input type='submit' value='ok'><br>"; echo "<br><br><a href='index.php?page=register'>Rejestracja</a>";
}