test: otw diambil bram
This commit is contained in:
parent
409d7dfe9f
commit
e1af8fc497
@ -114,5 +114,4 @@ function postScore(score){
|
|||||||
.then(t => console.log("Server response:", t))
|
.then(t => console.log("Server response:", t))
|
||||||
.catch(err => console.error("Fetch error:", err));
|
.catch(err => console.error("Fetch error:", err));
|
||||||
}
|
}
|
||||||
|
|
||||||
startQuiz()
|
startQuiz()
|
||||||
1
src/js/soal.js
Normal file
1
src/js/soal.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
dadad
|
||||||
@ -12,14 +12,14 @@ if (!isset($data['score'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$score = (int)$data['score'];
|
$score = (int)$data['score'];
|
||||||
$user_id = isset($_SESSION['user_id']) ? (int)$_SESSION['user_id'] : null;
|
$user_id = isset($_SESSION['id']) ? (int)$_SESSION['id'] : null;
|
||||||
|
|
||||||
if (!$user_id) {
|
if (!$user_id) {
|
||||||
echo json_encode(["error" => "no session user"]);
|
echo json_encode(["error" => "no session user"]);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$stmt = $db->prepare("INSERT INTO scores (user_id, score) VALUES (?, ?)");
|
$stmt = $db->prepare("INSERT INTO scores (id, score) VALUES (?, ?)");
|
||||||
$stmt->bind_param("ii", $user_id, $score);
|
$stmt->bind_param("ii", $user_id, $score);
|
||||||
|
|
||||||
if ($stmt->execute()) {
|
if ($stmt->execute()) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user