main
|
Last change
on this file was 75f74d9, checked in by Vlado 222039 <vlado.popovski@…>, 8 months ago |
|
Initial commit: Adding Book Tracker code
|
-
Property mode
set to
100644
|
|
File size:
595 bytes
|
| Line | |
|---|
| 1 | <?php
|
|---|
| 2 |
|
|---|
| 3 | require_once '../connect.php';
|
|---|
| 4 |
|
|---|
| 5 | header('Content-Type: application/json');
|
|---|
| 6 |
|
|---|
| 7 | if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|---|
| 8 | $userId = $_POST['userId'];
|
|---|
| 9 | $status = $_POST['status'];
|
|---|
| 10 |
|
|---|
| 11 | $query = "UPDATE member SET membership_status = :status WHERE userid = :userId";
|
|---|
| 12 | $stmt = $conn->prepare($query);
|
|---|
| 13 |
|
|---|
| 14 | try {
|
|---|
| 15 | $stmt->execute([
|
|---|
| 16 | ':status' => $status,
|
|---|
| 17 | ':userId' => $userId
|
|---|
| 18 | ]);
|
|---|
| 19 | echo json_encode(['success' => true]);
|
|---|
| 20 | } catch(PDOException $e) {
|
|---|
| 21 | echo json_encode(['success' => false, 'error' => $e->getMessage()]);
|
|---|
| 22 | }
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | ?>
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.