Ciao, perché questo listato che ho scritto mi da un notice al controllo per eseguire le sessioni:
come mai?
idee?
buona fine settimana.
PHP:
<html>
<head>
</head>
<style>
.tableheader {
background-color: #95BEE6;
color:white;
font-weight:bold;
}
.tablerow {
background-color: #A7D6F1;
color:white;
}
.message {
color: #FF0000;
font-weight: bold;
text-align: center;
width: 100%;
}</style>
<body>
<?php
session_start ();
$USERS["user"]['username'] = "luigi";
$USERS["user"]['password'] = "prova";
if (isset($_POST['submit']))
{
if(empty($_POST["utente"]))
{
$message = "Non inserito utente";
}elseif(empty($_POST["password"]))
{
$message= "Non inserito la password";
}else
{
// qui mi da errore e non fa il redirect alla pagina index.php
if ($USERS[$_POST["utente"]]['username'] == $_POST["utente"] && $USERS[$_POST["utente"]]['password'] == $_POST["password"])
{
$_SESSION['utente']=$_POST['utente'];
$_SESSION['login']=true;
header("Location: index.php");
}
else { $message= "Login errato";}
}
}
?>
<form name="frmUser" method="post" action="">
<div class="message"><?php if(isset($message)) { echo $message; } ?></div>
<table border="0" cellpadding="10" cellspacing="1" width="500" align="center">
<tr class="tableheader">
<td align="center" colspan="2">Login</td>
</tr>
<tr class="tablerow">
<td align="right">Username</td>
<td><input type="text" name="utente"></td>
</tr>
<tr class="tablerow">
<td align="right">Password</td>
<td><input type="password" name="password"></td>
</tr>
<tr class="tableheader">
<td align="center" colspan="2"><input type="submit" name="submit" value="Submit"></td>
</tr>
</table>
</form>
come mai?
idee?
buona fine settimana.