Webbserverprogrammering 1

Show sourcecode

The following files exists in this folder. Click to view.

webbutv3/word-app/api/

disable-translation.php
get-problem.php
scentence/
scentence.php
submit-problem-result.php

submit-problem-result.php

21 lines ASCII Windows (CRLF)
<?php

session_start
();

include 
"../util/db_connect.php";
include 
"../util/user.php";

if (
$_SERVER["REQUEST_METHOD"] == "POST") {

    
$jsonData file_get_contents('php://input');
    
// Decode the JSON data into a PHP associative array
    
$requestData json_decode($jsonDatatrue);

    
$userId user_id();
    foreach (
$requestData["translations"] as $transaltionResult) {
        
$stmt $db->prepare("INSERT INTO try_record (translation_id, success, `time`) VALUES(?, ?, ?)");
        
$time time();
        
$stmt->bind_param("iii"$transaltionResult["id"], $transaltionResult["success"], $time);
        
$stmt->execute();
    }
}