Buonasera a tutti,
volevo proporvi il mio problema:
Ho un login fatto in questo modo:
codice:
<?php
session_start();
ob_start();
?>
[...]
<?php
function check($user,$password){
include("online/utenti.php");
foreach($utenti as $user_ => $password_){
if (($user==$user_) && ($password==$password_)){
return true;
}
}
return false;
}
function form_login(){
?>
<form id="login" method="post" action="<?=$PHP_SELF?>">
[img]style/menu/accedi.gif[/img]
<table width="294" align="center">
<tr>
<th width="57" align="right" class="txtrosso-bold">user ID</th>
<td width="226" align="right"><input name="utente" value="inserire un valore valido" type="text" size="30" class="textfield" style="color: #999" maxlength="255" id="utente" onblur="this.value = this.value || this.defaultValue; this.style.color = '#999';" onfocus="this.value=''; this.style.color = '#000';">
</td>
</tr>
<tr>
<th align="right" class="txtrosso-bold">password</th>
<td align="right"><input name="password" value="password" type="password" size="30" class="textfield" style="color: #999" maxlength="255" id="password" onblur="this.value = this.value || this.defaultValue; this.style.color = '#999';" onfocus="this.value=''; this.style.color = '#000';"></td>
</tr>
</table>
<div id="space"></div>
<table width="300" align="center">
<tr>
<td width="272" align="right" valign="top"><input name="entra" type="image" src="style/entra.gif" alt="accedi" align="absbottom" /></td>
<td width="66" align="left">[img]style/chiudi.gif[/img]</td>
</tr>
</table>
</form>
<?php }
$user = $_POST["utente"];
if(isset($_POST["utente"])){
if (check($_POST["utente"],md5($_POST["password"]))){
$_SESSION["utente"] = $_POST["utente"];
$_SESSION["password"] = md5($_POST["password"]);
header("Location: online/index.php");
exit;
}else{
header("Location: online/login-failed.php");
}
}else{
form_login();
}
?>
</body>
</html>
Ovviamente ho un file php con la gestione utenti:
codice:
$utenti["admin"] = "blablabla";
La pagina protetta, ha questo codice iniziale:
codice:
<?php
session_start();
include("session.php");
$user = $_SESSION["utente"];
?>
Il mio problema è che i dati sono quasi sicuro che il sistema li prende, ma non mi fa il redirect nella pagina protetta.
Grazie a chi dovesse individuarmi l'errore.
Giuseppe