-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_skill.php
More file actions
42 lines (32 loc) · 1.11 KB
/
process_skill.php
File metadata and controls
42 lines (32 loc) · 1.11 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
<?php
session_start();
header('Content-Type: application/json');
require_once 'includes/config.php';
// Simulated data logic - Replace with DB interaction
if (!isset($_SESSION['skills'])) {
$_SESSION['skills'] = [];
}
$action = $_POST['action'] ?? '';
$skill = trim($_POST['skill'] ?? '');
switch ($action) {
case 'add_skill':
if ($skill && !in_array($skill, $_SESSION['skills'])) {
$_SESSION['skills'][] = $skill;
}
echo json_encode(['status' => 'success', 'skills' => $_SESSION['skills']]);
break;
case 'remove_skill':
if (($key = array_search($skill, $_SESSION['skills'])) !== false) {
unset($_SESSION['skills'][$key]);
$_SESSION['skills'] = array_values($_SESSION['skills']); // reindex
}
echo json_encode(['status' => 'success', 'skills' => $_SESSION['skills']]);
break;
case 'get_skills':
echo json_encode(['status' => 'success', 'skills' => $_SESSION['skills']]);
break;
default:
echo json_encode(['status' => 'error', 'message' => 'Invalid action']);
break;
}
?>