You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
708 B
PHTML
28 lines
708 B
PHTML
6 months ago
|
<?php
|
||
|
|
||
|
//php error messages on -- just for debugging
|
||
|
ini_set('display_errors', 1);
|
||
|
ini_set('display_startup_errors', 1);
|
||
|
error_reporting(E_ALL);
|
||
|
|
||
|
//save file name in variable
|
||
|
$filename = "form.json";
|
||
|
|
||
|
//get the data (name and post)
|
||
|
$name = $_GET['name'];
|
||
|
$post = $_GET['post'];
|
||
|
//save name and post in array with called "newpost"
|
||
|
$newpost = array("name" => $name, "post" => $post);
|
||
|
|
||
|
//open the file
|
||
|
$myfile = file_get_contents($filename);
|
||
|
//decode file to php data and store in array temp
|
||
|
$temp = json_decode($myfile);
|
||
|
//add the array newpost to the temp
|
||
|
array_push($temp, $newpost);
|
||
|
//enocde php data back to json
|
||
|
$json = json_encode($temp);
|
||
|
//save json to file name
|
||
|
file_put_contents($filename, $json);
|
||
|
|
||
|
?>
|