PHP 不显示错误并且 POST 不工作

PHP not displaying errors and POST not working

我正在开发一个带有 Ubuntu TLS Server 20.04 和 apache2 的网页。但是,我使用 000webhost 服务启动了该页面,并且 PHP 运行良好。显示了错误,我的 ESP-12f POST 请求也正常工作。

问题是现在没有显示错误并且 POST 不工作。我的 php 代码如下:

<?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);

这是加载此代码 (update.php) 时比较两个服务器操作的图片:https://i.stack.imgur.com/laWGP.jpg

这可能是由于服务器设置不同造成的,可能在 php.ini 中。尝试从

开始
<?php
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

您应该考虑过滤/您必须过滤 post 输入数据,请参阅 https://php.net/manual/de/function.filter-input.php。否则,您可能会让用户以 unwanted/insecure 方式访问您的文件系统,例如。 id = '../../bin/...' 或 '../../home/...'.

祝一切顺利!