Perchè nella query usi LIKE anzichè = ?
Comunque ho modificato leggermente il tuo script in quanto non avevo tempo/voglia di utilizzare il tuo script.. a me così funziona...
Mancava un ELSE nel caso non trovi l'accoppiamento user - password
Codice PHP:
<?php
ERROR_REPORTING(E_ALL);
function clear($clear){
return $clear;
}
if(isset($_POST['login'])) {
$username = isset($_POST['username']) ? clear($_POST['username']) : false;
$password = isset($_POST['password']) ? clear($_POST['password']) : false;
if(empty($username) || empty($password)) {
echo 'Riempi tutti i campi.<br /><br /><a href="javascript:history.back();">Indietro</a>';
} else {
//$password = md5($password);
$ip = $_SERVER['REMOTE_ADDR'];
if($username == "olo" && $password == "lol") {
$_SESSION['username'] = $username;
$_SESSION['ip'] = $ip;
header('Location: index.php');
}else{
header('Location: error.php');
}
}
} else {
echo <<<EOF
<form action="{$_SERVER['PHP_SELF']}" method="POST">
<label>Username: <input type="text" name="username" required maxlength="16" /></label><br />
<label>Password: <input type="password" name="password" required maxlength="20" /></label><br />
<input type="submit" name="login" value="Accedi" />
</form>
EOF;
}
?>