-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.js
64 lines (57 loc) · 2.31 KB
/
edit.js
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
function requestOtp() {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'otp.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
document.getElementById('otpRequestForm').style.display = 'none';
document.getElementById('verifyOTPForm').style.display = 'block';
} else {
}
}
};
xhr.send();
}
function verifyOTP() {
var otp = document.getElementById('otp').value;
var xhr = new XMLHttpRequest();
xhr.open('POST', 'votp.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
var response = JSON.parse(xhr.responseText);
if (response.success) {
document.getElementById('verifyOTPForm').style.display = 'none';
document.getElementById('updateForm').style.display = 'block';
} else {
document.getElementById('message').innerHTML = 'Failed to verify OTP.';
}
} else {
document.getElementById('message').innerHTML = 'Error verifying OTP.';
}
}
};
xhr.send('otp=' + otp);
}
function updateInfo() {
var name = document.getElementById('name').value;
var number = document.getElementById('number').value;
var xhr = new XMLHttpRequest();
xhr.open('POST', 'update_info.php', true);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.onreadystatechange = function() {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
var response = JSON.parse(xhr.responseText);
if (response.success) {
window.location.href = 'enter.html';
} else {
}
} else {
}
}
};
xhr.send('name=' + name + '&number=' + number);
}