<?
/*
   File name         : mailbox.php
   Version           : 1.1.3
   Last Modified By  : Umut Gokbayrak
   e-mail            : umut@trlinux.com
   Purpose           : Deletes the password from the BD and goes to the main webpage
   Last modified     : 7 Nov 2000
*/

include ("includes/global.inc");
session_start();

$ID=addslashes($_SESSION["ID"]);

// ID comparison between logged hash and session. If they are both the same, let the user to go on...
$dbq = $db->execute("select user_id,username,password from tblUsers where hash = '$ID'");
$user_id = $dbq->fields['user_id'];
$username = $dbq->fields['username'];
$password = $dbq->fields['password'];
$dbq->close();

if (($user_id == "") || (strlen($ID)==0)){
  Header("Location: index.php?error_id=1");
} else {

  // Borramos el hash de la BD para impedir que vuelva a entrar sin identificarse
  // y tambien borramos el password de su cuenta pop3, ya que no la necesitamos mienstras esta logged out
  $dbq = $db->execute("update tblUsers SET password='',hash='' where user_id = '$user_id'");
  $dbq->close();

  // Lo mismo para su variable de sesion
  session_unregister('ID');

  Header("Location: http://deim.etse.urv.es");
}
?>
