Search the Community
Showing results for tags '$input'.
-
Hello, I'm trying to edit the field of a page with a value from a javascript fetch post request but I can't get the file_get_contents("php://input") or $_POST value in my PHP file. I created a `update` template and a `update` page (to allow access from fetch request and avoid 404/403/... errors) containing this code : $data = file_get_contents('php://input'); echo $data; # test edit the page field with random value #$home = $pages->get("/"); #$home->of(false); #$home->testfield = "test value"; #$home->save(); # test fetch response with random value #echo "test fetch response"; That I fetch request with my client javascript like this : fetch('/update', { method: 'POST', body: 'test' }) .then(function(response) { return response.text(); }) .then(function(data) { console.log(data); }) .catch(error => console.log('error')) } The field edit works fine and I get the test response from the `update` file but I can't get the posted value, I only get `<empty string>`. It is working fine outside of ProcessWire so I guess this is related to how PW handle $_POST ? I found this post where it seems to be working : Is there any way to get post value from javascript fetch request? What am I doing wrong? Thank you
-
Hi everybody I want to catch a variable from outside processwire into _main.php if(isset($_GET['u']) && $_GET['u'] !== ''){ $gebruikersnaam = $_GET['u']; ... ... This is working fine in a php file in a non processwire environment. In a processwire environment, I get the variable when I refer to /site/templates/_main.php but a great part of my template-code is not shown. From outside processwire I refer to mydomain/index.php. If I place $gebruikersnaam = $_GET['u']; in index.php, how can I pass through my variable to _main.php? Or is there an other solution? thx hansv
- 6 replies
-
- url segments
- $input
-
(and 1 more)
Tagged with:
-
hey there, I was wondering what the best approach looks like to access the input (entity) body from a POST or PUT request. I didn't find anything in the docs if $input supports these. If anyone has dealt with this problem in the past I'd be happy to hear about your solutions Thanks & cheers!