-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetchCurrentFinish.php
More file actions
executable file
·53 lines (42 loc) · 1.26 KB
/
fetchCurrentFinish.php
File metadata and controls
executable file
·53 lines (42 loc) · 1.26 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
<?php
$conn = require __DIR__ . "/database.php";
session_start();
if (!isset($_SESSION["email"])) {
// Redirect to the login page if the user is not logged in
header('Location: index.php');
exit();
}
$email = mysqli_real_escape_string($conn, $_SESSION['email']);
$query = "SELECT * FROM account WHERE email='$email'";
$result = mysqli_query($conn, $query);
if ($row = mysqli_fetch_assoc($result)) {
$name = $row['userName'];
$password = $row['password'];
$phone = $row['phoneNum'];
$role = $row['role'];
} else {
// Handle case where email is not found in the database
$name = '';
$password = '';
$phone = '';
$role = '';
}
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if (isset($_POST['stepId'])) {
$stepId = $_POST['stepId'];
// Fetch the currentFinish value from the MySQL table
$query = "SELECT finish FROM projectstep WHERE id = '$stepId'";
$result = mysqli_query($conn, $query);
if ($result) {
$row = mysqli_fetch_assoc($result);
$currentFinish = $row['finish'];
echo $currentFinish; // Return the currentFinish value as the response
} else {
echo "Error fetching currentFinish";
}
} else {
echo "Invalid request";
}
mysqli_close($conn);