Codice PHP:
                if ($lostinfo == "password"){                     //if the user has lost his password he should insert his username and the system will send him a new default pwd                     ?>                   <h1>Password lost</h1>                                      <form name="adduser" method="post" action="lostpassword.php">                       

Insert your username 
                       <input type="text" name="username" /></p>                       

<input type="submit" name="Submit" value="Submit" align="center" /></p>                    </form>                    <?                          //define the receiver of the mail                   $user= $_POST['username'];                   $sql= "SELECT * FROM user WHERE username='".$user."'";                   $result = mysql_query($sql, $connection)                                       or die("Couldn't perform query $sql </br>".mysql_error());                   $row = mysql_fetch_array($result);                   if($row == null){                       echo "error";                   }                   $to = $row['email'];                   //define the subject of the email                   $subject = 'Password';                   //define the message to be sent. Each line should be separated with \n                   $message = "This mail is automatically generated.\nThe new password for the SOUND OFF Forum is password, you should change this password once logged in into the system\r\n";                   //define the headers we want passed. Note that they are separated with \r\n                   $headers = "From: admin-sound off-forum\r\nDo not reply to this email";                   //send the email                   //$mail_sent = mail( $to, $subject, $message, $headers );                   $mail_sent = mail( $to, $subject, $message );                   //if the message is sent successfully print "Mail sent". Otherwise print "Mail failed"                    //echo $mail_sent ? "Mail sent" : "Mail failed";                                      //set the default password as the password of the user                   $cryptedpwd=md5('password');                   $sql="UPDATE user SET password='".$cryptedpwd."' WHERE username= '".$user."'";                   $result = mysql_query($sql, $connection)                                       or die("Couldn't perform query $sql </br>".mysql_error());                                      if ($mail_sent) {                       echo "

Message successfully sent to".$row['email']."</p>";                   } else {                   echo "

Message delivery failed...</p>";                   }