OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
quiz
/
assets
/
process
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
02/15/2025 11:20:33 AM
rwxr-xr-x
📄
quiz_submit.php
1.28 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
quiz_submit_test.php
3 KB
05/19/2025 10:07:16 AM
rw-r--r--
📄
temp_answer.php
2.07 KB
05/19/2025 10:07:16 AM
rw-r--r--
Editing: quiz_submit.php
Close
<?php include('../php/db_config.php'); include('../php/validate.logged.php'); if (!empty($_POST)) { // Decode the JSON string into an array $formData = json_decode($_POST['formData'], true); $quizId = $_POST['quizId']; // Retrieve quizId if ($formData) { // Loop through each submitted answer foreach ($formData as $question_id => $selected_option) { // Prepare the SQL query to insert the user's answer $query = "INSERT INTO candidate_answer (que_id, user_id, answer, quiz_id) VALUES (?, ?, ?, ?)"; $stmt = $conn->prepare($query); $stmt->bind_param('iisi', $question_id, $gUserId, $selected_option, $quizId); // Bind parameters // Execute the query if (!$stmt->execute()) { echo "Error saving answer for question $question_id.<br>"; exit; } } // If all answers are successfully inserted, return a success message echo "Quiz submitted successfully!"; } else { // If formData is not in valid format echo "No valid answers submitted!"; } } else { // If no answers were submitted, return an error message echo "No answers were selected!"; } ?>