File size: 2.6Kb
<?php
require('includes/header.php');
require('includes/utils.php');
require('includes/db.php');
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$error = '';
$_POST = decode_array($_POST);
$users = mysql_query('SELECT email FROM users WHERE login = "' . addslashes($_POST['login']) . '"');
if(mysql_num_rows($users) == 0)
{
$error = 'Пользователь с таким именем не найден';
}
else
{
$user = mysql_fetch_array($users, MYSQL_ASSOC);
if($user['email'] != $_POST['email'])
{
$error = 'Неверно указан E-mail';
}
}
if($error != '')
{
?>
<wml>
<card id="error" title="error" ontimer="lostpassword.php"><timer value="15"/>
<p align="center">
<?php echo $error; ?>
</p>
</card>
</wml>
<?php
exit;
}
else
{
// generating and sending new password
$password = generatekey(8);
mysql_query('UPDATE users SET password = "' . md5($password) . '" WHERE login = "' . addslashes($_POST['login']) . '"');
mail($user['email'], 'New password', 'Your new password for WAP Builder: ' . $password);
?>
<wml>
<card id="ok" title="ok" ontimer="index.php"><timer value="15"/>
<do type="prev" label="назад"><prev/></do>
<p align="center">
<b>Ваш новый пароль сгенерирован и выслан на указанный вами при регистрации e-mail.</b>
</p>
</card>
</wml>
<?php
exit;
}
}
else
{
?>
<wml>
<card id="lostpassword" title="Склероз">
<p>
Ваш логин:<br/>
<input name="site" maxlength="15" title="Text"/><br/>
E-mail указанный при регистрации:<br/>
<input name="email" maxlength="40" title="Text"/><br/>
<anchor title="Sign">Ok<go href="lostpassword.php" method="post">
<postfield name="login" value="$(site)"/>
<postfield name="email" value="$(email)"/>
</go></anchor><br/>
<a href="index.php">Wap-builder</a>
</p>
</card>
</wml>
<?php
}
?>