-
Notifications
You must be signed in to change notification settings - Fork 13
/
review.html
130 lines (115 loc) · 5.18 KB
/
review.html
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Helpdesk</title>
<link rel="stylesheet" type="text/css" href="style.css?v=2" />
<link rel="icon" href="logo.png" type="image/png">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
</head>
<body>
<style>
#ale{
color: red;
}
</style>
<header class="navbar navbar-expand-md d-flex flex-wrap justify-content-center p-3 mb-2 border-bottom">
<div class="container-fluid">
<a href="#" class="d-flex align-items-center mb-3 mb-md-0 me-md-auto link-body-emphasis text-decoration-none">
<img src="logo.png" id="imglogo">
<span class="fs-4 mr-5 lo"><h2 class="bold-text">Helpdesk</h2></span>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#collapsibleNavbar">
<span class="navbar-toggler-icon"></span>
</button>
</div>
</header>
<div class="container mt-5">
<h2>Leave a Review</h2>
<p>We've noticed that you've used our app several times. Your valuable review helps us improve our app. We appreciate your feedback!</p>
<form id="reviewForm">
<div class="form-group">
<label for="review">Your Review:</label>
<textarea class="form-control" id="review" name="review" rows="3" placeholder="Write your review here" ></textarea>
</div>
<br>
<center><button id="su_btn" type="submit" class="btn btn-primary">Submit</button></center>
</form>
<div id="ale"></div>
<br>
<center><p><a href="join.html" style="color: green; text-decoration: none;">Join our Whatsapp group</a></p></center>
</div>
<br><br><br>
<hr>
<p style="padding: 10px;">Note: If you want to be a contributor in our app you can contact us.</p>
<center>
<p style="color: green;"> Whatsapp - +91 6207753704</p>
</center>
<script>
// Function to retrieve the value of a cookie by its name
function getCookie(cookieName) {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
// Check if the cookie starts with the desired name
if (cookie.startsWith(cookieName + '=')) {
return cookie.substring(cookieName.length + 1);
}
}
return null; // Return null if cookie not found
}
// Retrieve the username from the cookie
const username = getCookie('username');
console.log("Username:", username); // Log the username to check if it's retrieved correctly
// If the username is available, continue, else redirect to the login page
if (username) {
// Submit review form
document.getElementById('reviewForm').addEventListener('submit', function (event) {
event.preventDefault(); // Prevent the default form submission
// Get the review text from the form
const reviewText = document.getElementById('review').value;
// Check if the review text is not empty
if (reviewText.trim() === "") {
document.getElementById("ale").innerHTML = "<p>Please add a review before submitting.</p>";
} else {
document.getElementById("su_btn").style.display = "none";
// Prepare the data to be sent to the API
const data = {
username: username,
review: reviewText
};
console.log("Data:", data); // Log the data object to check its structure
// Send the data to the API endpoint
fetch('https://arambhsoftech.com/Helpdesk/submit_review.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': 'https://aman5062.github.io'
},
body: JSON.stringify(data)
})
.then(response => response.json())
.then(data => {
console.log("Response:", data); // Log the response from the API
// If the review was submitted successfully, set the 'reviewed' cookie to true
document.cookie = 'reviewed=true';
// Redirect to dbms.html after setting the cookie with a 2-second delay
setTimeout(function() {
window.location.href = 'dbms.html';
}, 1000); // 2000 milliseconds = 2 seconds
})
.catch(error => {
console.error('Error:', error); // Log any errors
// Handle errors if needed
});
}
});
} else {
// Redirect to the login page
window.location.href = "login.html";
}
</script>
</body>
</html>