# Send Data to PHP-File via POST

**URL:** <https://discourse.nodered.org/t/send-data-to-php-file-via-post/77990>\
**Category:** General\
**Created:** [27 April 2023 19:45 UTC](https://discourse.nodered.org/t/send-data-to-php-file-via-post/77990 "2023-04-27T19:45:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)\
**Post date:** [27 April 2023 19:45 UTC](https://discourse.nodered.org/t/send-data-to-php-file-via-post/77990/1 "2023-04-27T19:45:33Z")

</div>

Hey @ll,

atm iam looking for an Solution to send 2 Variables to an PHP-File.  
Maybe iam searching with the wrong Keywords, or iam Blind maybe both^^

The adress looks like this: [http://subdomain.tld.de/set.php?var1=1&var2=2](http://subdomain.tld.de/set.php?var1=1&var2=2)  
The PHP-File is saving the 2 variable to an textfile, if this information is needed.

I'll hope Someone can get me an Example how to send the Data to the PHP-File.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 April 2023 19:51 UTC](https://discourse.nodered.org/t/send-data-to-php-file-via-post/77990/2 "2023-04-27T19:51:18Z")

</div>

Have you looked at the http request node.  
e.g.

```auto
[{"id":"b55b432041f9355f","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"var1\":1,\"var2\":2}","payloadType":"json","x":180,"y":1040,"wires":[["0ea5c4df1261a275"]]},{"id":"0ea5c4df1261a275","type":"http request","z":"b9860b4b9de8c8da","name":"","method":"GET","ret":"txt","paytoqs":"query","url":"http://subdomain.tld.de/set.php","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"credentials":{"user":"","password":""},"x":350,"y":1040,"wires":[["674f72cc236a0785"]]},{"id":"674f72cc236a0785","type":"debug","z":"b9860b4b9de8c8da","name":"debug 287","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":510,"y":1040,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)\
**Post date:** [27 April 2023 20:10 UTC](https://discourse.nodered.org/t/send-data-to-php-file-via-post/77990/3 "2023-04-27T20:10:59Z")

</div>

Yeah but iam having some trouble with it.

The first variable is static, but the second isnt static.

 ![node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/d/5d47fd36d175a264e06eac74b1d2fa63bf58ae67.png)

At the end iam having trouble to get the second variable into the http-request.  
Atm the second variable is stored in msg.test

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [27 April 2023 20:32 UTC](https://discourse.nodered.org/t/send-data-to-php-file-via-post/77990/4 "2023-04-27T20:32:00Z")

</div>

Then use a change node to move or set the payload object, Payload wil be attached as a query string to the url in this example

```auto
[{"id":"b55b432041f9355f","type":"inject","z":"b9860b4b9de8c8da","name":"","props":[{"p":"payload"},{"p":"test","v":"2","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":130,"y":1040,"wires":[["c28d519b053c6a7c"]]},{"id":"c28d519b053c6a7c","type":"change","z":"b9860b4b9de8c8da","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.var1","tot":"msg"},{"t":"set","p":"payload.var2","pt":"msg","to":"test","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":1040,"wires":[["0ea5c4df1261a275"]]},{"id":"0ea5c4df1261a275","type":"http request","z":"b9860b4b9de8c8da","name":"","method":"GET","ret":"txt","paytoqs":"query","url":"http://subdomain.tld.de/set.php","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":510,"y":1060,"wires":[["674f72cc236a0785"]]},{"id":"674f72cc236a0785","type":"debug","z":"b9860b4b9de8c8da","name":"debug 287","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":670,"y":1060,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)\
**Post date:** [27 April 2023 20:45 UTC](https://discourse.nodered.org/t/send-data-to-php-file-via-post/77990/5 "2023-04-27T20:45:43Z")

</div>

I'll give it a try in some minutes/hours, my BananaPi is making some trouble^^

---

<div class="post-metadata">

**Author:** ![bgdev2015](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bgdev2015/32/67525_2.png) [@bgdev2015](https://discourse.nodered.org/u/bgdev2015)\
**Post date:** [2 May 2023 09:50 UTC](https://discourse.nodered.org/t/send-data-to-php-file-via-post/77990/6 "2023-05-02T09:50:29Z")

</div>

Sry for not responding, atm theres so much ive to do that iam not able to test it. Hopefully today at the evening.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [1 July 2023 09:51 UTC](https://discourse.nodered.org/t/send-data-to-php-file-via-post/77990/7 "2023-07-01T09:51:15Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
