cbreemer
Bronze Coder
Hey folks,
I hope someone can help explaining two PHP warnings.
My calling code is
My PHP file
In the debugger network tab I see these warnings:
The
so it seems to me the two parameters
And the PHP code, using these variables
So why the warnings ? I must be missing something obvious.
I hope someone can help explaining two PHP warnings.
My calling code is
JavaScript:
xhr.open('POST', "manfac.php", false);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(`func=facturen&name=*`);
My PHP file
manfac.php
starts with these lines:
PHP:
<?php
$func = $_POST["func"];
$name = $_POST["name"];
var_dump($_POST);
In the debugger network tab I see these warnings:
Code:
PHP Warning: Undefined array key "func" in C:\Users\cbree\OneDrive\manfac.php on line 3
PHP Warning: Undefined array key "name" in C:\Users\cbree\OneDrive\manfac.php on line 4
The
var_dump
command produces this info in the xhr return data:
Code:
array(2) {
["func"]=>
string(8) "facturen"
["name"]=>
string(1) "*"
}
func
and name
are correctly passed with their values facturen
and *
.And the PHP code, using these variables
$func
and $name
works as expected.So why the warnings ? I must be missing something obvious.