The client using XMLHttpRequest makes a request to the server and sends the data as an array: ["string1", "string2"]
But the client can, in principle, to forge the request and does not send data or send a blank line.
How to check data on the server to filter:
1) long string less than 5 characters
2) lack of values: $x[0] == null/undefined
Outline:
$x = json_decode(file_get_contents('php://input')); if( empty($x[0]) || empty($x[1]) ) { exit(); } if( !isset($x[0]) || !isset($x[1]) ) { exit(); } //or enough? : if( strlen($x[0]) <5 || strlen($x[1]) <5 ) { exit(); }