if(empty($_POST['name'])){
header("location:users_adduser.php?fail=1"); //no name specified
}
If I echo $_POST['name'] I can see that it is in fact empty. So what gives? How should I be checking for empty input fields?
Try
if (!isset($_POST['name'])){
header("location:users_adduser.php?fail=1"); //no name specified
}
According to the documentation, an empty string should be considered...well, empty. I'd try using var_dump() on $_POST and see what comes back, maybe it's not empty after all.
var_dump($_POST);
For testing purposes, comment out the header() call for now and perhaps just issue a print statement to ensure that it is actually evaluating to true. It could be a header redirect issue rather than a problem with empty().
if(empty($_POST['name'])){
// header("location:users_adduser.php?fail=1"); //no name specified
print("POST['name'] IS empty!");
}
var_dump($_POST)give you? Also, is error reporting turned on and do you get any errors?