Просмотр файла wapbuilder/admin/editpassword.php

Размер файла: 2.21Kb
<?php
require_once('includes/db.php');
require_once('includes/config.php');
require_once('includes/auth.php');

require_once('includes/header.php');

$error = '';
$message = '';
if(isset($_POST['edit']))
{
   if($_POST['password'] == '')
   {
      $error .= 'Enter new password!<br>';
   }
   if($_POST['repeat'] == '')
   {
      $error .= 'Enter password confirmation!<br>';
   }
   if($_POST['password'] != '' && $_POST['repeat'] != '')
   {
      if($_POST['password'] == $_POST['repeat'])
      {
         // изменяем данные пользователя
         mysql_query('UPDATE admins SET login = "' . $_POST['login'] . '", password = "' . md5($_POST['password']) . '" WHERE id = 1');
         $message = PASSWORD_CHANGED;
      }
      else
      {
         $error .= PASSWORDS_NOT_IDENTICAL;
      }
   }
}
?>
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="addbg"><td align="center" background="images/t5.gif"><font color="#FFFFFF"></font>
        <font class="header">
        <?php echo CHANGE_PASSWORD; ?>
      </font></td>
</tr></table><br>

<div align="center">
<font class="succ">
<?php echo $message; ?>
</font><br>
</div>

<div align="center">
<font class="error">
<?php echo $error; ?>
</font><br>
</div>

<?php

$users = mysql_query('SELECT login, password FROM admins WHERE id = 1');

$user = mysql_fetch_array($users, MYSQL_ASSOC);

?>

<br>

<table align="center" border="0">
<form action="" method="post">


<tr class="addbg"><td width="50%">
<?php echo LOGIN; ?>
</td><td width="50%">
<input type="text" name="login" value="<?php echo $user['login']; ?>" maxlength="255">
</td>
</tr>

<tr class="addbg"><td width="50%">
<?php echo NEW_PASSWORD; ?>
</td><td width="50%">
<input type="password" name="password" value="" maxlength="255">
</td>
</tr>

<tr><td width="50%">
<?php echo CONFIRM_PASSWORD; ?>
</td><td width="50%">
<input type="password" name="repeat" value="" maxlength="255">
</td>
</tr>

<tr class="addbg"><td colspan="2" align="center">
<br>
<input type="submit" name="edit" value="  <?php echo EDIT; ?>  ">
<br><br>
</td></tr>


</form>

</table>

<?php
require_once('includes/footer.php');
?>