<? 

//if (!$_SESSION['nick'] AND !$_SESSION['login'] )
//{
// header("Location:main.php");
// exit;
//}

if ($_SESSION['nick'] )
{
 include("./config.php"); 
 $sq = "select * from users where userid='$_SESSION[userid]' ";
 $ab=MySQL_Query($sq );
 while($ff=mysql_fetch_array($ab))
 {
   $camp=$ff["PASSWORD"];
 }
 if ($heslo==1)
 {
  if ($nove==$nove2)
  {
   $db_password = md5($stare);
   if ($db_password ==$camp)
   {
    $db_password = md5($nove);
    @$pridej = MySQL_query( "UPDATE users SET PASSWORD='$db_password'  WHERE userid='$_SESSION[userid]' ");   
    echo "<H4>Heslo bylo uspěšně změněno.</H4>";
   }
   else	
   {
    echo "<H4>Špatné staré heslo.</H4>";
   }
  }
  else	
  {
   echo "<H4>Nová hesla se nechodují.</H4>";
  }
 }

?>

    	 <H2>Change your account</H2>

  	<br />
  	<br />


 <table border="0" cellpadding="0" cellspacing="3" >
 <FORM method=post action="main.php?title=ucty&heslo=1#heslo">
  <tr>
   <td align="right">Old password
   </td>
   <td>
    <input type="password" name="stare" size="20">
   </td>
  </tr>

  <tr>
   <td align="right">New password
   </td>
   <td><input type="password" name="nove" size="20">
   </td>
  </tr>

  <tr>
   <td align="right">Pepeat new password</td>
   <td ><input type="password" name="nove2" size="20"></td>
  </tr>
    <tr>
   <td ></td>
   <td > <input type=submit value="Ulož"></td>
  </tr>
 </form>
 </table>
 

<hr width="300" align="left">

<? 

 if ($mail==1)
 {
    @$pridej = MySQL_query( "UPDATE users SET email='$email2'  WHERE userid='$_SESSION[userid]' ");   
    echo "<H4>E-mail byl uspěšně změněn.</H4>";
 }
   
 $sq = "select * from users where userid='$_SESSION[userid]' ";
 $ab=MySQL_Query($sq );
 while($ff=mysql_fetch_array($ab))
 {
   $email=$ff["email"];
 }

 echo"    	 <H2>E-mail for send reports</H2>
  	<br />
  	<br />

 <FORM method=post action=\"main.php?title=ucty&mail=1#mail\">

 <table border=\"0\" cellpadding=\"0\" cellspacing=\"3\" >

  <tr>
   <td  align=\"right\">E-mail
   </td>
   <td>
    <input type=\"text\" name=\"email2\" size=\"20\" value=$email>
   </td>
  </tr>
  
  <tr>
   <td  align=\"right\"></td>
   <td>
     <input type=submit value=\"Ulož\">
   </td>
  </tr>
  

 </form>
 </table>
 

 ";
}
?>
