xref: /web-php/include/posttohost.inc (revision 1ebc2c49)
1<?php
2
3/*
4 This code is used to post data to the central server which
5 can store the data in database and/or mail notices or requests
6 to PHP.net stuff and servers
7*/
8
9function posttohost($url, $data)
10{
11    $data = http_build_query($data);
12
13    $opts = [
14        'method' => 'POST',
15        'header' => 'Content-type: application/x-www-form-urlencoded',
16        'content' => $data,
17    ];
18
19    $ctx = stream_context_create(['http' => $opts]);
20
21    return file_get_contents($url, false, $ctx);
22}
23