connect_error) { die("Connection failed: " . $conn->connect_error); } // Assuming the user's id is available in a session or passed to this script $user_id = $_SESSION['user_id']; // Replace with your actual user identification method // Retrieve POST data from the questionnaire form $q1_option = $_POST['q1']; // Assuming 'q1' is the name of the first question radio button group $q2_option = $_POST['q2']; // Assuming 'q2' is the name of the second question radio button group $q3_option = $_POST['q3']; // Assuming 'q3' is the name of the third question radio button group // Save scores to the database $sql = "INSERT INTO user_scores (user_id, q1_option, q2_option, q3_option) VALUES ('$user_id', '$q1_option', '$q2_option', '$q3_option')"; if ($conn->query($sql) === TRUE) { echo "Scores saved successfully"; } else { echo "Error: " . $sql . "
" . $conn->error; } $conn->close(); ?>