2   require 'include/head.inc';
 
   3   require 'include/db.inc';
 
   4   require 'include/common.inc';
 
   6   if(isset($_POST['submit']) && $_POST['mnumber']!="") {
 
   7     $mnumber = trim($_POST['mnumber']);
 
   9     if( ! is_numeric($mnumber) ) {
 
  10       block("red", "Mat.nummer has to be numeric!");
 
  13       if($db->query("SELECT COUNT(*) FROM students WHERE mnumber = $mnumber")->fetch(PDO::FETCH_NUM)[0] == 0) {
 
  14         print '<table bgcolor="red">';
 
  15         print '<tr><th><b><font color="white">Mat.nummer not found</font></b></th><tr>';
 
  19         $userinfo = $db->query("SELECT firstname,lastname,email,password FROM students WHERE mnumber=$mnumber")->fetch(PDO::FETCH_NUM);
 
  21         // send password-email //
 
  22         $nachricht = "Hello $userinfo[0]($mnumber)!\nThis is a password-recovery mail for the exercise " . $PREFS['exname'] . " (" . $PREFS['groupname'] . ").\nYour forgotten password is: $userinfo[3]\n\nYours,\nBanana.";
 
  23         $header = 'From: banana@treefish.org' . "\r\n" .
 
  24         'Reply-To: noreply@treefish.org' . "\r\n" .
 
  25         'X-Mailer: PHP/' . phpversion();
 
  26         mail($userinfo[2], "Banana password-recovery: " . $PREFS['exname'] . " (" . $PREFS['groupname'] . ")", $nachricht, $header);
 
  28         print "<table bgcolor=\"lightgreen\">";
 
  29           print "<tr><th><b><font color=\"white\">sent password to your email-address</font></b></th><tr>";
 
  36 <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
 
  37   <table bgcolor="black">
 
  38     <tr><th><b><font color="white">Password recovery</font></b></th><tr>
 
  43       <th align="left">Mat.nummer:</th> <th align="left"><input type="text" name="mnumber"></th>
 
  45     <tr><th colspan=2></th></tr>
 
  48       <th align="left"><input type="submit" name="submit" value="Recover password"></th> <th></th>