{"action":"created","issue":{"url":"https://api.github.com/repos/ebeshero/phpStuff/issues/1","repository_url":"https://api.github.com/repos/ebeshero/phpStuff","labels_url":"https://api.github.com/repos/ebeshero/phpStuff/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/ebeshero/phpStuff/issues/1/comments","events_url":"https://api.github.com/repos/ebeshero/phpStuff/issues/1/events","html_url":"https://github.com/ebeshero/phpStuff/issues/1","id":153859609,"number":1,"title":"POST experiment","user":{"login":"ebeshero","id":4014518,"avatar_url":"https://avatars.githubusercontent.com/u/4014518?v=3","gravatar_id":"","url":"https://api.github.com/users/ebeshero","html_url":"https://github.com/ebeshero","followers_url":"https://api.github.com/users/ebeshero/followers","following_url":"https://api.github.com/users/ebeshero/following{/other_user}","gists_url":"https://api.github.com/users/ebeshero/gists{/gist_id}","starred_url":"https://api.github.com/users/ebeshero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebeshero/subscriptions","organizations_url":"https://api.github.com/users/ebeshero/orgs","repos_url":"https://api.github.com/users/ebeshero/repos","events_url":"https://api.github.com/users/ebeshero/events{/privacy}","received_events_url":"https://api.github.com/users/ebeshero/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-09T20:14:54Z","updated_at":"2016-05-09T22:51:50Z","closed_at":null,"body":"@djbpitt I've attempted to adapt your PHP-GET sequence of files to do the same thing with POST, and I'm not quite succeeding. Here's what I've done:\r\n\r\n* So as not to confuse any files we worked on with the POST experiment, I created a new subdirectory named \"post\" underneath \"phpStuff\" in my Apache server. The POST experiment currently lives here: http://digitalmitford.org/phpStuff/post/lettersInterface.html\r\nAnd I uploaded a lettersInterface.html with a new series of PHP files renamed in camelcase as postyears.php, postLetterList.php, and postLetterText.php\r\n\r\n* All of these files are also currently in a new \"POST\" directory on this GitHub repo. I also created slightly modified alternate XQuery scripts in my eXist db to fire the relevant \"post\" PHP files. \r\n\r\n* postYears.php is identical to getYears.php (since neither of these is using GET or POST, but initiating the sequence---it just fires a script that returns the years). So of course this is working still.\r\n\r\n* [postLettersList.php](https://github.com/ebeshero/phpStuff/blob/master/POST/postLetterList.php) is supposed to generate the list of letters on click of a year, and currently it's only delivering results because I forced it to with $_GET applied in what is otherwise (I think) a 'method'==> 'POST' context. I know this is behaving like GET or basically *is* GET.  Here's the relevant code:\r\n````\r\n<?php\r\n    require_once(\"config.php\");\r\n    $year = htmlspecialchars($_GET[\"year\"]);\r\n//ebb: when I change this to $_POST, I generate an HTML page with the h1 element, but no PHP generated output.\r\n    $url = REST_PATH . \"/db/queries/postLetterList.xql?year=$year\";\r\n$data = array('type' => 'input', 'target' => $year);\r\n$options = array(\r\n    'http' => array(\r\n        'header'  => \"Content-type: application/x-www-form-urlencoded\\r\\n\",\r\n        'method'  => 'POST',\r\n        'content' => http_build_query($data)\r\n    )\r\n);\r\n    $context = stream_context_create($options);\r\n    $result = file_get_contents($url, false, $context);\r\n    echo $result;\r\n?>\r\n````\r\nIf I try this:  `$year = htmlspecialchars($_GET[\"year\"]);` it doesn't work, and I think that must be where I'm declaring the $data variable as an array, or earlier where I'm attempting to retrieve the input variable (the information retrieved from mouse-click). So I forced the above PHP to work with GET so I could see if could try to use POST on the *next* stage, to retrieve the text of a letter.\r\n\r\n* The next stage, at [postLetterText.php](https://github.com/ebeshero/phpStuff/blob/master/POST/postLetterText.php) told me something more. Here's the PHP code:\r\n````\r\n<?php\r\n    require_once(\"config.php\");\r\n    $uri = htmlspecialchars($_POST[\"uri\"]);\r\n    $contents = REST_PATH . \"/db/queries/letterText.xql?uri=$uri\";\r\n$data = array('type' => 'input', 'target' => $uri);\r\n$options = array(\r\n    'http' => array(\r\n        'header'  => \"Content-type: application/x-www-form-urlencoded\\r\\n\",\r\n        'method'  => 'POST',\r\n        'content' => http_build_query($data)\r\n    )\r\n);\r\n    $context = stream_context_create($options);\r\n    $result = file_get_contents($contents, false, $context);\r\n    echo $result;\r\n?>\r\n````\r\nWith this, I generate an HTML page with the h1 element, and evidently part of my XQuery script is firing, but failing to retrieve the \"uri\" parameter, because I generate PART of the transformed XSLT file but the letter is missing! The XSLT is evidently firing to produce the basic template of the page but fails to retrieve and transform the XML file.\r\nAnd once again, if I change the value of $uri to include $_GET instead of $_POST, I do successfully retrieve the XML file and the value of $uri appears in the browser.\r\n   "},"comment":{"url":"https://api.github.com/repos/ebeshero/phpStuff/issues/comments/218013240","html_url":"https://github.com/ebeshero/phpStuff/issues/1#issuecomment-218013240","issue_url":"https://api.github.com/repos/ebeshero/phpStuff/issues/1","id":218013240,"user":{"login":"ebeshero","id":4014518,"avatar_url":"https://avatars.githubusercontent.com/u/4014518?v=3","gravatar_id":"","url":"https://api.github.com/users/ebeshero","html_url":"https://github.com/ebeshero","followers_url":"https://api.github.com/users/ebeshero/followers","following_url":"https://api.github.com/users/ebeshero/following{/other_user}","gists_url":"https://api.github.com/users/ebeshero/gists{/gist_id}","starred_url":"https://api.github.com/users/ebeshero/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ebeshero/subscriptions","organizations_url":"https://api.github.com/users/ebeshero/orgs","repos_url":"https://api.github.com/users/ebeshero/repos","events_url":"https://api.github.com/users/ebeshero/events{/privacy}","received_events_url":"https://api.github.com/users/ebeshero/received_events","type":"User","site_admin":false},"created_at":"2016-05-09T22:51:50Z","updated_at":"2016-05-09T22:51:50Z","body":"@djbpitt Okay--everything's POSTal now, including XQuery scripts, which now have no GET strings. What I don't understand is how the last XQuery in the cycle is passing a URI to letterText.xql, which is the same lettertext.xql we used in the GET cycle. With the GET version, we handed the letterText.php a  GET string with the uri variable encoded inside, like this:\r\n\r\n````\r\nreturn   \r\n<li xmlns=\"\"><a href=\"LetterText.php?uri={tokenize($LT/base-uri(), '/')[last()]}\">{$LT/replace(.,'\\W+$','')}</a></li> \r\n````\r\n\r\nNow, in the POST universe, we just set the URL to \r\n````\r\n <li xmlns=\"\"><a href=\"postLetterText.php\">{$LT/replace(.,'\\W+$','')}</a></li>\r\n````\r\nand I really have no idea how the uri variable is retrieving the appropriate uri, since all it's getting from the XQuery now is...a snip of text from a file as the link text(?) How on earth or in the transit of Mercury across the sun are we getting a file name in the $uri variable now? "}}