So for the past couple of days I've been trying to get messages sent through an online form to send to my printer URL and automatically print. After much effort I finally got the PHP working last night and was over the moon. When I pressed send, the printer printed the latest message sent via the form. Set the printer up again a while ago and sent a message through the form..and nothing.. No new messages are appearing in my printer archive and I didn't touch or even open the PHP code on the webpage since last night when everything was working. There are no errors on the webpage when I send a message and messages are saving to the database but not sending to the printer anymore. Can anyone explain this?
Here is a video of it working last night:
https://www.youtube.com/watch?v=ltz-vinhIHg
And here's the section of PHP that was sending the messages to the archive last night:
if ($message != null)
{$qry = "INSERT INTO names1 (name, time, date)
VALUES ('$message', CURRENT_TIME, CURRENT_DATE);";
$insert = mysqli_query ($db, $qry);
$id = mysqli_insert_id($db);
$printer_id = '6g2o1s6t0f4e7v4a';
$print_url = 'http://printer.exciting.io/print/' . $printer_id;
$fields = array(
'content' => ( '<h1>' . $message . '</h1>')
);
function http_post_lite($url, $data) {
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
),
);
$context = stream_context_create($options);
return $result = file_get_contents($url, false, $context);
}
$response = http_post_lite($print_url, $fields);
}