-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
80 lines (80 loc) · 3.2 KB
/
index.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
68
69
70
71
72
73
74
75
76
77
78
79
80
<!DOCTYPE html>
<html>
<head>
<title>
Log On form
</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css?v=0.0.1">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
</head>
<body>
<div style="display: flex; justify-content: space-between; align-items: center;">
<h1 id="title-logon">Student Log In</h1>
<div id="logout"></div>
</div>
<hr>
<div class="wrapper-main" id="app">
<form action="" method="post" onsubmit="processdata(); return false;">
<input name="name" type="text" placeholder="name" class="input-b" id="name" required>
<input name="email" type="email" placeholder="email" class="input-b" id="email" required>
<input name="contact" type="number" placeholder="contact" class="input-b" id="number" required>
<input type="submit" class="button">
</form>
</div>
<script>
function reset() {
$("#title-logon").text("Student Log In");
$("#logout").html("");
$("#app").html(`
<form action="" method="post" onsubmit="processdata(); return false;">
<input name="name" type="text" placeholder="name" class="input-b" id="name" required>
<input name="email" type="email" placeholder="email" class="input-b" id="email" required>
<input name="contact" type="number" placeholder="contact" class="input-b" id="number" required>
<input type="submit" class="button">
</form>
`);
}
function processdata() {
var name = $("#name").val();
var email = $("#email").val();
var contact = $("#number").val();
$.ajax({
url: "data.php",
method: "POST",
data: {
name: name,
email: email,
contact: contact
},
success: function(response) {
$("#app").html(response);
$("#logout").html('<h3 class="reset" onclick="reset();">Log Out</h3>');
},
error: function() {
$("#app").html("houston, we got a problem");
}
});
}
</script>
<style>
.reset {
cursor: pointer;
}
.reset:hover {
text-decoration: underline;
}
th {
padding: 0.5em 1em;
}
td {
padding: 0.5em 1em;
border-top: 1px solid #000;
border-bottom: 1px solid #000;
background: antiquewhite;
border-left: 25px solid antiquewhite;
border-right: 25px solid antiquewhite;
}
</style>
</body>
</html>