Advertisement
Guest User

tes

a guest
Jan 11th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.22 KB | None | 0 0
  1. <?php
  2. session_start();
  3.  
  4. use PHPMailer\PHPMailer\PHPMailer;
  5.  
  6.  
  7.  
  8. if(isset($_POST['email'])){
  9. $con = new mysqli('localhost', 'root', '', 'app_pos');
  10.  
  11. $email = $con->real_escape_string($_POST['email']);
  12.  
  13. $sql = $con->query("SELECT id FROM users WHERE email='$email'");
  14. if ($sql->num_rows > 0){
  15.  
  16. $token = "123456789qwertyuiop";
  17. $token = str_shuffle($token);
  18. $token = substr($token, 0, 10);
  19.  
  20. $con->query("UPDATE users SET token='$token',
  21. tokenExpire=DATE_ADD(NOW(), INTERVAL 5 MINUTE)
  22. WHERE email='$email'
  23.  
  24. ");
  25.  
  26. require_once "PHPMailer/PHPMailer.php";
  27. require_once "PHPMailer/Exception.php";
  28.  
  29. $mail = new PHPMailer();
  30. $mail->addAddress($email);
  31. $mail->setFrom("hello@momnjo.com", "xxx");
  32. $mail->Subject = "Reset Password";
  33. $mail->isHTML(true);
  34. $mail->Body = "
  35. Hi,<br><br>
  36.  
  37. If you want reset Password, Please click on the link below:<br>
  38. <a href='
  39. http://localhost/momnjoone/changepassword.php?email=$email&token=$token
  40. '>http://localhost/momnjoone/changepassword.php?email=$email&token=$token</a><br><br>
  41.  
  42. Best Regards,<br>
  43. HR MomNJo
  44.  
  45. ";
  46.  
  47.  
  48. if($mail->send())
  49. echo "check your email";
  50.  
  51. // exit(json_encode(array("status" => 0, "msg" => 'Somethig Wrong Just Happened!')));
  52.  
  53.  
  54. }else
  55. echo "check again";
  56. // exit(json_encode(array("status" => 0, "msg" => 'Please Check your inputs!')));
  57. }
  58.  
  59. ?>
  60.  
  61. <!DOCTYPE html>
  62. <html>
  63. <head>
  64. <meta charset="utf-8">
  65. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  66. <meta name="description" content="A fully featured admin theme which can be used to build CRM, CMS, etc.">
  67. <meta name="author" content="Coderthemes">
  68.  
  69. <link rel="shortcut icon" href="assets/images/favicon_1.ico">
  70.  
  71. <title>Forgot password</title>
  72.  
  73. <link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
  74. <link href="assets/css/core.css" rel="stylesheet" type="text/css" />
  75. <link href="assets/css/components.css" rel="stylesheet" type="text/css" />
  76. <link href="assets/css/icons.css" rel="stylesheet" type="text/css" />
  77. <link href="assets/css/pages.css" rel="stylesheet" type="text/css" />
  78. <link href="assets/css/responsive.css" rel="stylesheet" type="text/css" />
  79. <script src="assets/js/modernizr.min.js"></script>
  80.  
  81. </head>
  82. <body>
  83.  
  84. <div class="account-pages"></div>
  85. <div class="clearfix"></div>
  86.  
  87. <div class="wrapper-page">
  88. <div class="card-box">
  89. <div class="panel-heading">
  90. <h3 class="text-center"> Forgot Password</h3>
  91. </div>
  92.  
  93. <div class="panel-body">
  94.  
  95. <form class="form-horizontal m-t-20" action="" method="post">
  96.  
  97. <div class="form-group has-feedback">
  98. <div class="col-xs-12">
  99. <input class="form-control" id="email" type="text" placeholder="Email" name="email" value ="">
  100. <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
  101. </div>
  102. </div>
  103.  
  104. <div class="form-group text-center m-t-40">
  105. <div class="col-md-12">
  106. <!-- -->
  107. <button class="btn btn-pink btn-block text-uppercase waves-effect waves-light" type="submit" value = "forgotpassword" name = "forgotpassword">
  108. Submit
  109. </button>
  110. <br><br>
  111. <p id='response'></p>
  112. </div>
  113.  
  114. </div>
  115.  
  116. </form>
  117.  
  118. </div>
  119. </div>
  120.  
  121. </div>
  122.  
  123. <script>
  124. var resizefunc = [];
  125. </script>
  126.  
  127.  
  128. <script
  129. src="http://code.jquery.com/jquery-3.3.1.min.js"
  130. integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
  131. crossorigin="anonymous">
  132. </script>
  133. <script type="text/javascript">
  134. var email = $("#email");
  135. $(document).ready(function(){
  136. $('.btn-pink').on('click', function(){
  137. if(email.val() != ""){
  138. email.css('border', '1px solid green');
  139. $.ajax({
  140. url: 'password.php',
  141. method: 'POST',
  142. dataType: 'json',
  143. data: {
  144. email: email.val()
  145. }, success: function(response){
  146. if (!response.success)
  147. $("#response").html(response.msg).css('color', "red");
  148. }
  149.  
  150. });
  151. }else
  152. email.css('border', '1px solid red');
  153.  
  154.  
  155. });
  156. });
  157. </script>
  158. </body>
  159. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement