Как восстановить пароль на php?

делаю восстановление пароля, но застрял: никак не могу понять как же сделать восстановление пароля?

<?php
define('FROM_EMAIL', '[email protected]');


function restore($email) {
    include SITE_ROOT.'libs/mail.php';
  $hash = generateHash();

  $database = connectDatabase();

  $is_email_exist = $database->prepare("SELECT `id` , `hash`, `timestamp_created`, `email` FROM `restore` WHERE `email` = :email");
  $is_email_exist->execute(array(':email' => '3'));
  $row1 = $is_email_exist->fetch(PDO::FETCH_ASSOC);
  if(!empty($row1['id'])) {
    if($row1['timestamp_created'] < (time() + 3600000 *3) ) {
        $mail = new Mail;
        $mail->setEmail('[email protected]');

        $mail->send($row1['email'], 'Восстанволение пароля', 'Здрваст вуйте, мы хотим восстановит<a href="/restore.php?act=restore&email='.FROM_EMAIL.'&hash='.$row1['hash'].'"></a>');

    }
  } else {


$hash= 12;


  $database = connectDatabase();


  $database = connectDatabase();
  $is_email_exist = $database->prepare("INSERT INTO `restore`(`id`,
                                                             `email`,
                                                             `hash`,
                                                             `timestamp_created`,
                                                             `owner_id`) VALUES (
                                                             '',
                                                             '3',
                                                             '3',
                                                             '3',
                                                             '3')");

  $is_email_exist->execute(array(':email' => '',
                                 ':hash' => 'f',
                                 ':timestamp_created' => 2342,
                                 ':owner_id' => '213'));
  $row1 = $is_email_exist->fetch(PDO::FETCH_ASSOC);

        $mail = new Mail('[email protected]', 'Иван');


        $mail->send('[email protected]', 'Восстанволение пароля', 'Здрваст вуйте, мы хотим восстановит<a href="/restore.php?act=restore&[email protected]&hash='.$hash.'"></a>');

        var_dump('sended');


  }

}

function checkRestore($hash, $email) {
  $database = connectDatabase();

  $is_email_exist = $database->prepare("SELECT `id` , `hash`, `timestamp_created`, `email` FROM `restore` WHERE `email` = :email AND `hash` = :hash");
  $is_email_exist->execute(array(':email' => '3'));
  $row1 = $is_email_exist->fetch(PDO::FETCH_ASSOC);
  if(!empty($row1['id'])) {
    if($row1['timestamp_created'] > (time() + 3600000 *3) ) {
echo 'time is out';
    } else {
        include 'cgane password form';

    }
  } else {


}

function savePassword($email) {


  $is_email_exist = $database->prepare("UPDATE `users` SET `hashed_password` = :hashed_password, `salt` =:salt  WHERE `email` = :email");
  $is_email_exist->execute(array(':email' => '3',
                                 ':hashed_password' =>'y',
                                 ':salt'=>'sadsa'));
  $row1 = $is_email_exist->fetch(PDO::FETCH_ASSOC);



}

}
?>

Ответы (0 шт):