I am at register.php
now. I will be grateful for explanation why !isset()
doesn't do the job while empty()
perfectly does.
For example,
if (empty($_POST["username"])) {
apologize("Please, provide your username.");
}
does lead to a message "Sorry! Please, provide your username".
But
if (!isset($_POST["username"])) {
apologize("Please, provide your username.");
}
leads to a blank page with no messages if I don't enter the username.
I have read the question on Stack Overflow What's the difference between 'isset()' and '!empty()' in PHP? and it seems that both should work fine for the above stated purpose.
$_POST["username"]
stores when the user submits the form without filling the username field?$_POST["username"]
will store NULL in such case, and thus it will be set, so isset will be true? While empty() checks if the user did type any letters, is it correct?