Guest User

code 2

a guest
Mar 14th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. else{
  2. $expFormat = mktime(
  3. date("H")+1, date("i"), date("s"), date("m") ,date("d"), date("Y")
  4. );
  5. $expDate = date("Y-m-d H:i:s",$expFormat);
  6. $key = md5(2418*2+$staffId);
  7. $addKey = substr(md5(uniqid(rand(),1)),3,10);
  8. $key = $key . $addKey;
  9. // Insert Temp Table
  10. mysqli_query($con,
  11. "INSERT INTO `password_reset_temp` (`staffId`, `key`, `expDate`)
  12. VALUES ('".$staffId."', '".$key."', '".$expDate."');");
  13.  
  14. $output='<p>Dear user,</p>';
  15. $output.='<p>Please click on the following link to reset your password.</p>';
  16. $output.='<p>-------------------------------------------------------------</p>';
  17. $output.='<p><a href="http://localhost/forgot-password/reset-password.php?
  18. key='.$key.'&staffId='.$staffId.'&action=reset" target="_blank">
  19. https://localhost/forgot-password/reset-password.php?key='.$key.'&staffId='.$staffId.'&action=reset</a></p>';
  20.  
  21. $output.='<p>-------------------------------------------------------------</p>';
  22. $output.='<p>Please be sure to copy the entire link into your browser.
  23. The link will expire after 1 hour for security reason.</p>';
  24. $output.='<p>If you did not request this forgotten password email, no action
  25. is needed, your password will not be reset. However, you may want to log into
  26. your account and change your security password as someone may have guessed it.</p>';
  27. $output.='<p>Thanks,</p>';
  28. $output.='<p>Administrator</p>';
  29. $body = $output;
  30. $subject = "Password Reset - Bonafide System ";
  31.  
  32. $email_to = $email;
  33. $fromserver = "noreply@localhost";
  34. require("PHPMailer/PHPMailerAutoload.php");
  35. $mail = new PHPMailer();
  36. $mail->IsSMTP();
  37. $mail->Host = "mail.localhost"; // Enter your host here
  38. $mail->SMTPAuth = true;
  39. $mail->Username = "noreply@localhost"; // Enter your email here
  40. $mail->Password = "password"; //Enter your password here
  41. $mail->Port = 25;
  42. $mail->IsHTML(true);
  43. $mail->From = "noreply@localhost";
  44. $mail->FromName = "Administrator";
  45. $mail->Sender = $fromserver; // indicates ReturnPath header
  46. $mail->Subject = $subject;
  47. $mail->Body = $body;
  48. $mail->AddAddress($email_to);
  49. if(!$mail->Send()){
  50. echo "Mailer Error: " . $mail->ErrorInfo;
  51. }else{
  52. echo "<div class='error'>
  53. <p>An email has been sent to you with instructions on how to reset your password.</p>
  54. </div><br /><br /><br />";
  55. }
  56. }
  57. }else{
  58. ?>
  59. <form method="post" action="" name="reset"><br /><br />
  60. <label><strong>Enter Your Email Address:</strong></label><br /><br />
  61. <input type="text" name="staffId" placeholder="Staff ID" />
  62. <br /><br />
  63. <input type="submit" value="Reset Password"/>
  64. </form>
Add Comment
Please, Sign In to add comment