fixed multiple things
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
require_once('Connections/bkngstm.php');
|
||||
|
||||
$conn = new mysqli($servername, $username, $password, $dbname);
|
||||
|
||||
if ($conn->connect_error) {
|
||||
die(json_encode(['success' => false, 'error' => 'Connessione fallita: ' . $conn->connect_error]));
|
||||
}
|
||||
|
||||
if (isset($_POST['userid']) && isset($_POST['lessonnotification'])) {
|
||||
$userid = $_POST['userid'];
|
||||
$lessonnotification = $_POST['lessonnotification'];
|
||||
|
||||
// Validate lessonnotification value
|
||||
if (!in_array($lessonnotification, ['Y', 'N'])) {
|
||||
echo json_encode(['success' => false, 'error' => 'Valore lessonnotification non valido']);
|
||||
exit;
|
||||
}
|
||||
|
||||
$query = "UPDATE auth_users SET lessonnotification = ? WHERE id = ?";
|
||||
$stmt = $conn->prepare($query);
|
||||
$stmt->bind_param("si", $lessonnotification, $userid);
|
||||
|
||||
if ($stmt->execute()) {
|
||||
echo json_encode(['success' => true]);
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => $conn->error]);
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
echo json_encode(['success' => false, 'error' => 'Parametri mancanti']);
|
||||
}
|
||||
|
||||
$conn->close();
|
||||
Reference in New Issue
Block a user