Webbserverprogrammering 1

Show sourcecode

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

webbsrvprg/gya/

index.js
index.php
javascript.js
jsonIndex.json
save.json
test.php

index.php

28 lines UTF-8 Windows (CRLF)
<!DOCTYPE html>
<html lang="sv">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport">
    <title>Första sidan</title>
  </head>

  <body>
    <?php 
      
if (isset($_POST["actions"]) && isset($_POST["time"])) {
        
$json json_encode("{".$_POST["time"].",".$_POST['actions']."}");

        echo 
json_decode($json)."<br>";

        
file_put_contents("jsonIndex.json"$jsonFILE_APPEND);
      }
    
?>

    <form method="POST" action="">
      <input type="hidden" id="time" name="time">
      <input type="hidden" id="actions" name="actions">
      <input type="submit" value="Skicka">
    </form>

    <script src="javascript.js"></script>
  </body>
</html>