<?php require('SRC/config.php3'); require('SRC/macros.php3'); 
list ($home,$url,$users,$assign,$msg,$host,$sql,$MYCookie,$applet,$os)=courseAll();

myheader('Remind password','..',0);		# Header

if($email == ""){
  echo "<form action=remind.php3 method=post> ";
  echo "Email: <input type=text size=60 name=email><p>";
  echo "       <input type=submit value=Send> a reminder by email</form> ";

} else {
  $database = pg_Connect($host, "", "", "", $sql);
  if(!$database){echo "Internal error 1<br>";exit();}

  $cmd = "SELECT user_name,user_passwd FROM users WHERE user_email='" . 
              str_replace("'", " ", $email) . "';";
  if(!($result=pg_exec($database,$cmd))){echo "Internal error 2<br>";exit();}
  if(pg_numrows($result) == 0){
    echo "The user ".$email." has not been registred... sorry!";
  } else {
    $user_name   = pg_result($result,0,user_name);
    $user_passwd = pg_result($result,0,user_passwd);
    $mail = "Dear " . $user_name . "\n\n" .
      "In reply to your request, here is a reminder of your password: ".
      $user_passwd."\n\nBest wishes,\nYour Webmaster.";
    mail($email, "PDE course password", $mail,
	 "From: webmaster@$SERVER_NAME\n".
         "Reply-To: jaun@fusion.kth.se\nX-Mailer: PHP/".
	 phpversion());
    echo "A reminder has been sent by email to " . $email . "\n";
  } // if
  pg_Close($database);
} // if

?>

<!-- ******START OF BODY FOOTER***** -->
<br><p>
<address>
 <table border="0" background="IMAGES/background_tile.png" cellpadding="5" width="811" cellspacing="0">
  <tr align="bottom">
  <td class="lll" nowrap>
   <a href=javascript:history.go(-1) onMouseover="window.status=' # previous'; return true"
     ><img src="IMAGES/nav_previous.png" alt="back" width=16 height=16 border="0" align="bottom"></a>
   <a href="#" onMouseover="window.status=' # top'; return true"
     ><img src="IMAGES/nav_up.png" alt="up"  width=16 height=16 border="0" align="bottom"></a>
   <a href=javascript:history.go(1) onMouseover="window.status=' # next'; return true"
     ><img src="IMAGES/nav_next.png" width=16 height=16 alt="next" border="0" align="bottom"></a>
  </td>
  <td class="lll" nowrap><b><font color="#FFFFFF">&copy;&nbsp;2004
     <A HREF=http://www.lifelong-learners.com><font color="#FFFFFF">www.lifelong-learners.com</font></A> &amp; 
     <A HREF=http://www.nada.kth.se/~jaun><font color="#FFFFFF">Andr&eacute; JAUN</font></A>,&nbsp; NADA, Royal Institute of Technology, Stockholm</font></b></td>
 </table>
</address>
<br>
<!-- ******END OF BODY FOOTER****** -->
</BODY>
</HTML>
