-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.js
64 lines (50 loc) · 1.74 KB
/
code.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
let BaseUrl = "https://sheetdb.io/api/v1/l3so05n3czwyh"
loginBtn = document.getElementById("loginbtn");
loginBtn.addEventListener("click",async(evt)=>{
evt.preventDefault();
let warn = document.getElementById("warn");
let gmail = document.getElementById("gmail").value;
let password = document.getElementById("password").value;
console.log(gmail,password);
let responce = await fetch(BaseUrl);
let data = await responce.json();
console.log(data);
console.log(data[0].gmail);
let flag = 0;
for( let rec in data){
if(data[rec].gmail === gmail){
flag = 1;
if(data[rec].password === password){
console.log("login succesful")
window.location.href = 'main.html';
break;
}
else{
console.log("Enter valid password")
warn.innerText = "Enter Valid Password";
}
}
}
if(flag != 1){
console.log("Gmail not found, Please enter a valid Gmail")
warn.innerText = "Gmail not found, Please enter a valid Gmail";
}
})
function signinpg(){
window.location.href = 'sign.html';
}
function loginpg(){
window.location.href = 'index.html';
}
var form = document.getElementById("sheetdb-form");
form.addEventListener("submit",e=>{
e.preventDefault();
fetch(form.action,{
method:"POST",
body:new FormData(document.getElementById("sheetdb-form")),
}).then(
response => response.json()
).then((html)=>{
window.open('index.html','_blank');
});
});