POST data to permant json file using PHP

Posted by doxsi on Stack Overflow See other posts from Stack Overflow or by doxsi
Published on 2012-07-04T14:59:03Z Indexed on 2012/07/04 15:15 UTC
Read the original article Hit count: 209

Filed under:
|

using a url, my idea is the any user can post data. For example via

http://myweb.com/index.php?name=Peter&surname=Brown

Using the "jedwards" answer, present here , I am hable to create a json an d save it to a file.

<?
/* This needs to be at the top of your file, without ANYTHING above it */
session_start();

/* ... */

if(!array_key_exists('entries', $_SESSION))
{
    $_SESSION['entries'] = array();
}

$_SESSION['entries'][] = array("name" => $_GET["name"], "surname" => $_GET["surname"]);

$json_string = json_encode($_SESSION['entries']);

My problem is taht his is not permant amongst different session or user. It work only on the same session. On different sessionthe json built start from the beginning.

Any idea about that?

© Stack Overflow or respective owner

Related posts about php

Related posts about JSON