-
Notifications
You must be signed in to change notification settings - Fork 0
/
forget_password.php
67 lines (58 loc) · 2.41 KB
/
forget_password.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html>
<head>
<title>Forgot Password</title>
<script>
document.addEventListener('DOMContentLoaded', () => {
const button = document.getElementById('submit-button');
const timeoutKey = 'lastClickedTime';
const timeoutDuration = 5 * 60 * 1000; // 5 minutes in milliseconds
// Check if the button should be disabled
const lastClickedTime = localStorage.getItem(timeoutKey);
if (lastClickedTime && Date.now() - lastClickedTime < timeoutDuration) {
disableButton(button);
const remainingTime = timeoutDuration - (Date.now() - lastClickedTime);
startCountdown(remainingTime, button);
}
// Add event listener for the button
button.addEventListener('click', (e) => {
if (button.disabled) {
e.preventDefault();
alert('You can only request a code once every 5 minutes.');
return;
}
// Store the current time in localStorage
localStorage.setItem(timeoutKey, Date.now());
disableButton(button);
startCountdown(timeoutDuration, button);
});
// Function to disable the button
function disableButton(btn) {
btn.disabled = true;
}
// Function to enable the button
function enableButton(btn) {
btn.disabled = false;
}
// Function to start the countdown
function startCountdown(duration, btn) {
const countdownInterval = setInterval(() => {
const timeLeft = Math.max(0, duration - (Date.now() - lastClickedTime));
if (timeLeft <= 0) {
clearInterval(countdownInterval);
enableButton(btn);
}
}, 1000);
}
});
</script>
</head>
<body>
<h2>Forgott Password</h2>
<form method="POST" action="https://youbee.click/send_email_password.php">
<label for="email">Enter your email:</label>
<input type="email" id="email" name="email" required>
<button id="submit-button" type="submit">Send Verification Code</button>
</form>
</body>
</html>