Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- else{
- $expFormat = mktime(
- date("H")+1, date("i"), date("s"), date("m") ,date("d"), date("Y")
- );
- $expDate = date("Y-m-d H:i:s",$expFormat);
- $key = md5(2418*2+$staffId);
- $addKey = substr(md5(uniqid(rand(),1)),3,10);
- $key = $key . $addKey;
- // Insert Temp Table
- mysqli_query($con,
- "INSERT INTO `password_reset_temp` (`staffId`, `key`, `expDate`)
- VALUES ('".$staffId."', '".$key."', '".$expDate."');");
- $output='<p>Dear user,</p>';
- $output.='<p>Please click on the following link to reset your password.</p>';
- $output.='<p>-------------------------------------------------------------</p>';
- $output.='<p><a href="http://localhost/forgot-password/reset-password.php?
- key='.$key.'&staffId='.$staffId.'&action=reset" target="_blank">
- https://localhost/forgot-password/reset-password.php?key='.$key.'&staffId='.$staffId.'&action=reset</a></p>';
- $output.='<p>-------------------------------------------------------------</p>';
- $output.='<p>Please be sure to copy the entire link into your browser.
- The link will expire after 1 hour for security reason.</p>';
- $output.='<p>If you did not request this forgotten password email, no action
- is needed, your password will not be reset. However, you may want to log into
- your account and change your security password as someone may have guessed it.</p>';
- $output.='<p>Thanks,</p>';
- $output.='<p>Administrator</p>';
- $body = $output;
- $subject = "Password Reset - Bonafide System ";
- $email_to = $email;
- $fromserver = "noreply@localhost";
- require("PHPMailer/PHPMailerAutoload.php");
- $mail = new PHPMailer();
- $mail->IsSMTP();
- $mail->Host = "mail.localhost"; // Enter your host here
- $mail->SMTPAuth = true;
- $mail->Username = "noreply@localhost"; // Enter your email here
- $mail->Password = "password"; //Enter your password here
- $mail->Port = 25;
- $mail->IsHTML(true);
- $mail->From = "noreply@localhost";
- $mail->FromName = "Administrator";
- $mail->Sender = $fromserver; // indicates ReturnPath header
- $mail->Subject = $subject;
- $mail->Body = $body;
- $mail->AddAddress($email_to);
- if(!$mail->Send()){
- echo "Mailer Error: " . $mail->ErrorInfo;
- }else{
- echo "<div class='error'>
- <p>An email has been sent to you with instructions on how to reset your password.</p>
- </div><br /><br /><br />";
- }
- }
- }else{
- ?>
- <form method="post" action="" name="reset"><br /><br />
- <label><strong>Enter Your Email Address:</strong></label><br /><br />
- <input type="text" name="staffId" placeholder="Staff ID" />
- <br /><br />
- <input type="submit" value="Reset Password"/>
- </form>
Add Comment
Please, Sign In to add comment