Advertisement
Guest User

Untitled

a guest
Sep 9th, 2017
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.06 KB | None | 0 0
  1.  
  2.    
  3. $mysqli = new MySQLi($mysql['host'],$mysql['user'],$mysql['pass'],$mysql['db']) or die($mysqli->error);
  4. $account="someemail@gmail.com";
  5. $password="somepass";
  6.  
  7.  
  8.  
  9. include("lib/phpmailer/PHPMailerAutoload.php");
  10.  
  11.         function FilterInput($string)
  12.     {
  13.         $string = htmlentities($string);
  14.         $string = mysqli_real_escape_string($string);
  15.         return $string;
  16.     }
  17.     function random_string($length) {
  18.         $key = '';
  19.         $keys = array_merge(range(0, 9), range('a', 'z'));
  20.  
  21.     for ($i = 0; $i < $length; $i++) {
  22.         $key .= $keys[array_rand($keys)];
  23.     }
  24.  
  25.     return $key;
  26. }
  27.  
  28.  
  29.  
  30.     if(isset($_POST['passwordForgot']))
  31.     {
  32.         $email = filter_var($_POST['email'], FILTER_SANITIZE_EMAIL);
  33.         if (filter_var($email, FILTER_VALIDATE_EMAIL) === false) {
  34.         }
  35.         $result = $mysqli->query('SELECT id, mail from users WHERE mail = "'. $email. '"');
  36.         if (mysqli_num_rows($result) > 0)
  37.         {
  38.  
  39.             while ($row = mysqli_fetch_assoc($result))
  40.             {
  41.                
  42.                 $token = random_string(50);
  43.                 $mysqli->query('INSERT INTO `nabbo_tokens` (`user_id`, `token`) VALUES ("'. $row['id']. '", "'.$token. '")');
  44.                 $mysqli->query('INSERT INTO `nabbo_token_logs` (`user_id`, `action`) VALUES ("'. $row['id']. '", "changed password via token")');
  45.            
  46.                
  47.                
  48.                 $mail = new PHPMailer();
  49.                
  50.                 $mail->IsSMTP();
  51.                 $mail->CharSet = 'UTF-8';
  52.                 $mail->Host = "smtp.gmail.com";
  53.                 $mail->SMTPAuth= true;
  54.                 $mail->Port = 465;
  55.                 $mail->Username= $account;
  56.                 $mail->Password= $password;
  57.                 $mail->SMTPSecure = 'ssl';
  58.                 $mail->From = "kpro.server@gmail.com";
  59.                 $mail->FromName= "Runo Hotel - Müşteri Hizmetleri";
  60.                 $mail->isHTML(true);
  61.                 $mail->Subject = "Müşteri Hizmetleri – Şifremi unuttum";
  62.                 $mail->Body = 'body message';
  63.                 $mail->addAddress($email);
  64.                 $mail->SMTPDebug = 0;
  65.                 $geluktWachtwoord = true;
  66.                 $geluktWachtwoord = "Basari";
  67.             if(!$mail->send()){
  68.  die ("Mailer Error: " . $mail->ErrorInfo);
  69.             }
  70.  
  71.             }
  72.         }
  73.         else{
  74.                 $errorWachwoordLog = true;
  75.                 $errorWachwoordLog = "Geçersiz bir e-posta adresi girdiniz.";
  76.                
  77.         }
  78.    
  79.     }
  80.  
  81. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement