olaf, like I already said, I tried your original snippet of code and it works with register_globals off (so it must be your logic/code). So, now I took a look at your check_empty_fields() function, which has a few things wrong with it.
Regarding this line:
$field_name = (array_key_exists($key, $req_fields)) ? $req_fields[$key] : $key;
I don't see the point of allowing an associative array, like your example of 'timestamp' => 'Your time' (unless that is meant to hold the name of the form field). The way you have it now, $field_name would contain 'Your time' as a value, which I believe is not what you meant to have happen. The "in_array($field_name, $req_fields)" part may not make a match.
Regarding this line:
if (in_array($field_name, $req_fields) && $val == "") {
This is flawed because if the field key doesn't exist at all then it won't count as an error. It only counts as an error if the key exists and it's an empty string value. Well, if it's a required field and it doesn't even exist, then it should be counted as an error too. Maybe you want to use the empty() function instead of an empty string value.
It might be a good idea to check get_magic_quotes_gpc() and stripslashes() if necessary before evaluating the $val variable is empty or not.
The other minor problem I see is if the $GET or $POST has no values at all, then the foreach loop won't even be executed, and I would consider that a loop hole/error.
Tips:
If you do this:
define('REQ_METHOD', $_SERVER['REQUEST_METHOD']);
then you can use that as the default method in the function:
function check_empty_fields($method = REQ_METHOD) {
This line doesn't take into consideration if someone was to pass the method value in upper case (or mixed case):
$data_array = ($method == "post") ? $POST : $GET;
Maybe change it to something like this:
$data_array = ('POST' == strtoupper($method)) ? $POST : $GET;
or reference it instead:
if ('POST' == strtoupper($method))
$data_array = & $_POST;
else
$data_array = & $_GET;
hth.