my Problem is the following:
I have an Apache Server running on an RaspberryPi. I try to make a http POST with paramaters as follows:
http://192.168.178.43/update-led.php/?api_key=tPmAT5Ab3j7F9
Here you can see a picture of it in Postman: POSTMAN Form
However in the php code which gets called in update-led.php file I get the error:
PHP Notice: Undefined index: api_key in /var/www/html/update-led.php on line 31
Here is the Code from the update-led.php file:
$api_key = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (isset($_POST["api_key"])){// returns false
$api_key = test_input($_POST["api_key"]);
if($api_key == $api_key_value) {
//do something
}
}
} else{
echo "No Api Key provided"
}
}
I also get the http result "No Api Key provided" which means the isset($_POST['api_key']) command returns false.
I can't find the mistake which I am making and the strange thing is, that the api_key is already working in an http GET request with the following Code:
if ($_SERVER["REQUEST_METHOD"] == "GET") {
$api_key = test_input($_GET["api_key"]);
if($api_key == $api_key_value) {
//do something
}
}
Thank you for your help, i hope I didn't forget any important Information. Paul