Scusate..ho un problema nel mio sito..quando mi connetto mi da un errore di questo tipo: Notice: Undefined index: id in c:\program files\easyphp1-8\www\copia tesina\prova.php on line 3. Se schiaccio entra, inserisco l' id e password..entra normalmente, se faccio logout esce...senza nessun' altro errore..mi da errore solo quando entro di nuovo. Se io invece entro, c' è sempre quell' errore, clicco su login, inserisco id e password, mi connetto e chiudo la pagina. Quando rientro non mi da più nessun errore e giustamente mi dice...sei già entrato. Qualcuno mi potrebbe dare una mano a creare un login che non mi dia nessun errore..oppure a risolvere il mio errore? Vi posto il codice:
clienti.html (dove inserisco id e password):
<html>
<head>
<title>clienti</title>
</head>
<body bgcolor="darkorange">
<center>
<table border="5">
<tr>
<td>
<a href="home.html">
[img]hhome.jpg[/img]
</a>
</td>
<td>
<a href="Storia.html">
[img]nnostra.jpg[/img]
</a>
</td>
<td>
<a href="dove.html">
[img]ddove.jpg[/img]
</a>
</td>
<td>
<a href="http://pizzas.forumup.it/">
[img]fforum.jpg[/img]
</a>
</td>
<td>
<a href="Amministratore.html">
[img]aaministratore.jpg[/img]
</a>
</td>
<td>
<a href="registra.html">
[img]rregistra.jpg[/img]
</a>
</td>
<td>
<a href="pizze.html">
[img]vvolantino.jpg[/img]
</a>
</td>
</tr>
</table>
</center>
<form method="post" action="clienti.php">
<input type="text" name="id" />Inserisci id
<input type="password" name="pass" />Inserisci la password
<input type="submit" value="INSERISCI" />
<input type="reset" value="CANCELLA" />
</form>
</body>
</html>
clienti.php (dove ricevo id e password e creo la var di sessione):
<?php session_start() ;
?>
<html>
<head>
<title>clienti</title>
</head>
<body bgcolor="darkorange">
<?php
$con=mysql_connect("localhost","root","");
mysql_select_db('pizzeria');
$id=$_POST["id"];
$pass=$_POST["pass"];
$_SESSION['id']=$id;
$query="select id from cienti where id='$id'";
$query4="select password from cienti where id='$id'";
$query5="select id from cienti where password='$pass'";
$ris5=mysql_query($query5);
if (!$ris5)
{
print"ATTENZIONE...ERRORE NELLA QUERY5";
exit();
}
$riga5=mysql_fetch_array($ris5);
$ris4=mysql_query($query4);
if (!$ris4)
{
print"ATTENZIONE...ERRORE NELLA QUERY4";
exit();
}
$riga4=mysql_fetch_array($ris4);
$ris=mysql_query($query);
if (!$ris)
{
print"ATTENZIONE...ERRORE NELLA QUERY";
exit();
}
$riga=mysql_fetch_array($ris);
if (!$riga)
{if (!$riga5)
{
print"ATTENZIONE...NON SEI REGISTRATO";
print" Per registrarti clicca qui";
}else
{
print("ATTENZIONE...ID ERRATO");
exit();
}
}else
{if ($riga4['password']<>$pass)
{
print("ATTENZIONE...PASSWORD ERRATA");
exit();
}else
{
$query1="select codc from cienti where id='$id'";
$ris=mysql_query($query1);
if (!$ris)
{
print"ATTENZIONE...ERRORE NELLA QUERY1";
exit();
}
$riga1=mysql_fetch_array($ris);
$query2="select max(numero) as max from ordine";
$ris1=mysql_query($query2);
if (!$ris1)
{
print"ATTENZIONE...ERRORE NELLA QUERY2";
exit();
}
$nr=mysql_fetch_array($ris1);
$numm=$nr['max'];
$numm=$numm+1;
$dat=date("d.m.y");
$query3="insert into ordine (numero,codc,data,totpre,definito) values ('$numm','$riga1[codc]','$dat','0','n')";
$ris2=mysql_query($query3);
print"Accesso effettuato clicca qui";
}
}
mysql_close($con);
?>
</body>
</html>
prova2.php (logout):
<?php
session_start();
$id=$_SESSION['id'];
unset($_SESSION['id']);
header("Refresh: 4;URL=home.html");
echo '<div align="center">Arrivederci</div>';
?>
prova.php (è la pagina dove fa il controllo se è vuota la var di sessione, ed è quella che se è vuota mi apre clienti.html se è piena mi apre direttamente l' area ris ai clienti):
<?php
session_start();
if (!$_SESSION['id'])
{
print"entra";
}else{
print "entrato";
}
?>
Giustamente l' errore dice, var di sessione non definita, perchè prima chiedo se è nulla, se è nulla apro la pagina di login dove passo l' id. quando faccio il logout la elimino. Non riesco a trovare una soluzione migliore..perfavore aiutatemi...grazie