I am developing a web page with an Ubuntu TLS Server 20.04 with apache2. However, I started the page with 000webhost service and PHP worked great. The errors were displayed and my ESP-12f POST requests were working as well.
The thing is that now the errors aren't displayed and the POST is not working. My php code is the following:
<?php
date_default_timezone_set("Europe/Madrid");
$doorId = $_POST["door"];
$id = $_POST["id"];
$data = $doorId ." ". $id . " " . date("H:i:s d/m/Y") . "\n";
$file = '../logs/'.$id.'.php';
file_put_contents($file, $data, FILE_APPEND);
This is a picture comparing both servers actions when this code (update.php
) is loaded: https://i.sstatic.net/laWGP.jpg
This may be caused be different server settings, probably in php.ini. Try starting with
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
You should consider filtering / you have to filter your post input data, see https://php.net/manual/de/function.filter-input.php. Otherwise you possibly let users access your file system in an unwanted/insecure manner, eg. id = '../../bin/...' or '../../home/...'.
All the best!