Eccovi il codice
Codice PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<style type = "text/css">
body { background-color: #1c445e; }
a:link, a:visited, a:active, a:hover { text-decoration: none }
.p1 { color: white; font-weight:bold; font-family:"GOTHIC"; }
</style>
<script>
function error1() {
alert('Le due password non corrispondono');
location.reload('utente.html');
}
function error2() {
alert('La vecchia password non corrisponde');
location.reload('utente.html');
}
function save() {
alert('Password modificata');
location.reload('index.html');
}
</script>
</head>
<BODY>
<p class="p1">
<?php
$pass1 = @$_GET['pass1'];
$pass2 = @$_GET['pass2'];
$pass3 = @$_GET['pass3'];
if ($pass2 == $pass3) {
$var = file('../mdb-database/clienti.txt');
$fc = fopen('../mdb-database/clienti.txt', 'w+') or die('errore nell\'apertura del file');
for($r=0;$r<count($var);$r++) {
$var[$r]=explode(";",$var[$r]);
if (trim($var[$r][8]) == $pass1) {
$var[$r][8] = $pass2;
for($i=0;$i<count($var);$i++) {
fwrite($fc, $var[$i][0]);
fwrite($fc, ";");
fwrite($fc, $var[$i][1]);
fwrite($fc, ";");
fwrite($fc, $var[$i][2]);
fwrite($fc, ";");
fwrite($fc, $var[$i][3]);
fwrite($fc, ";");
fwrite($fc, $var[$i][4]);
fwrite($fc, ";");
fwrite($fc, $var[$i][5]);
fwrite($fc, ";");
fwrite($fc, $var[$i][6]);
fwrite($fc, ";");
fwrite($fc, $var[$i][7]);
fwrite($fc, ";");
fwrite($fc, $var[$i][8]);
fwrite($fc, "\n");
fclose($fc);
}
echo "<script>save()</script>";
} else {
echo "<script>error2()</script>";
return 0;
}
}
}
if ($pass2 <> $pass3) {
echo "<script>error1()</script>";
}
?>
</body>
</html>