<?php

$info = '';
$html->PrgStart();
if($player->Check())
{
  if(array_key_exists('zmenit', $_POST) and ($_POST['zmenit'] == 1))
  {
    $account = $_POST['acc1'];
    $email1 = $_POST['email1'];
    $email2 = $_POST['email2'];

    $db->select_db($Config['Mangos']['DatabaseRealmd']);
    $DbResult = $db->query('select id from account where username="'.$account.'" and email="'.$email1.'"');
    if($DbResult->num_rows > 0)
    {
      $email_update = $db->query('update account set email="'.$email2.'" where username="'.$account.'"');
      if($email_update)
      {
        $info = '<font color="green"><strong>Email byl vpořádku změněn!</strong></font>';
      } else
      {
        $info = '<font color="red"><strong>Email se nepodařilo změnit!</strong></font>';
      }
    } else $info = '<font color=red><b>Zadali jste špatný stávající email nebo neexistující účet!</b></font>';
  }


  echo('&nbsp;<a href="'.$html->Link('/ucet/').'">&lt;- Zpět do správy účtu</a><br />');

  echo('<b>'.$info.'</b>
<form method="post" action="'.$html->Link('/ucet/zmena-emailu/').'">
<center><h3>Změna e-mailu</h3></center>

<table align="center">
 <input type="hidden" name="acc1" value="'.$_SESSION['UserName'].'" />
  <tr>
    <td>
      Starý e-mail : </td>
    <td>
      <input type="text" name="email1" autocomplete="off" /></td>
  </tr>
  <tr>
    <td>
      Nový e-mail : </td>
    <td>
      <input type="text" name="email2" autocomplete="off" /></td>
  </tr>
  <tr>
    <td colspan="2" align="right">
  <input type="hidden" name=zmenit value="1" />
      <input type="submit" value="Změnit" name="change" /></td>
  </tr>
</table>
</form>');
} else
{
  $player->LoginForm();
}
$html->PrgStop();

?>
