è un semplice esercizio sull'autenticazione basic http.
praticamente una volta autenticato mi si dovrebbe aprire un form per la modifca dei dati col tasto "salva modifiche".
dov'è l'errore?probabilmente è un errore logico..ma leggendolo non vedo intoppi,quindi credo che esuli dalle mie conoscenze
se il codice nn è chiaro dite pure..


Codice PHP:
<?
$user
=$_SERVER['PHP_AUTH_USER'];
$pwd=$_SERVER['PHP_AUTH_PW'];

    
$pos=verify($user,$pwd);
    if(!isset(
$pwd)|| $pos<0)
    {
        
header('WWW-Authenticate:Basic realm="protetto"');
        
header('HTTP/1.1 401 Unauthorized');
        echo 
"<h2>Errata autorizzazione...</h2>";
    }
    else{
    
    
/*clicco save*/
    
if (isset($_GET['save'])){
        
/*$stampa_aggiornati=false;*/
        
$auth=$_GET['auth'];
        
$db fopen("db.txt","r+");
        
        while (!
feof($db)){
            
$buffer=fgets($db);
            
$riga=explode(";","$buffer");
            
                if (
$auth[0]==$riga[0]) {
                
/*foreach*/
                
$auth[4]==$riga[4];
                
$auth[3]==$riga[3];
                
$auth[2]==$riga[2];
                
$auth[1]==$riga[1];
                
$newdata=implode(";","$auth");
                
fputs("$db","$newdata");
                }
                
        }
    
fclose($db);
    }
    
    
    
    
/*FUNZIONE VERIFICA*/
    
function verify($user$pwd){
    
$file=fopen("db.txt","r");
    
$i=0;
    while(!
feof($file)){
        
$temp=fgets($file);
        
$riga=explode(";",$temp);
        
$i++;
        if(
$user==$riga[0]&&$pwd==$riga[4])    return $i;
            
    }
    
fclose($file);
    return -
1;
    }
    
    
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>auth</title>
</head>

<body>
<h1 align="center"> form http-auth basic </h1>
<form action="<? $_SERVER['PHP_SELF'?>" method="get">
<table align="center">
<tr><td>
nome </td><td><input type="text" name="auth[]" value="<? echo $auth[1?>" /></td></tr>
<tr><td>
cognome </td><td><input type="text" name="auth[]"value="<? echo $auth[2?>" /></td></tr>
<tr><td>
professione </td><td> <input type="text" name="auth[]"value="<? echo $auth[3?>" /></td></tr>
<tr><td>password</td><td><input type="password" name="auth[]"value="<? echo $auth[4?>"  /></td></tr>
<tr><td colspan="2" align="center"><input type="submit" value="save"/></td></tr>

</table>
</form>
</body>
</html>


db.txt del tipo[user;nome;cognome;lavoro;password]
esempio:
codice:
user1;anto;alt;ricott;aabc;
user2;peppe;alt;ricott;def;