-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.php
More file actions
38 lines (33 loc) · 883 Bytes
/
Copy pathfunctions.php
File metadata and controls
38 lines (33 loc) · 883 Bytes
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
<?php
// Function to validate and sanitize input data
function validate($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
// Function to redirect with message
function redirect($location, $message = '') {
if (!empty($message)) {
echo "<script>alert('$message');</script>";
}
echo "<script>window.location.href='$location';</script>";
exit();
}
// Function to check if user is logged in
function isLoggedIn() {
return isset($_SESSION['email']);
}
// Function to get current user email
function getCurrentUserEmail() {
return $_SESSION['email'] ?? '';
}
// Function to get current user name
function getCurrentUserName() {
return $_SESSION['name'] ?? '';
}
// Function to get current user image
function getCurrentUserImage() {
return $_SESSION['image'] ?? '';
}
?>