tags:

views:

27

answers:

2

Hello,

if($username=="") {
    $login_domain_error="Enter User Name";
}

if(isset($_POST['passwd'])) {
    $login_p_error="Enter Password";

When I enter the above two validation, it triggers the validation errors, without form submission using PHP

What exactly is wrong

Thanks Jean

+2  A: 

Well, you're checking if $_POST['passwd'] is set, and if that's the case, you define an error.

Daniel Egeberg
No I am checking if $_post['passwd'] is null, but then I used is_empty(_post['passwd']) too, with the same auto trigger for form error
Jean
isset() doesn't check for null values - it checks whether the variable exists but doesn't care whether it actually contains anything. Use print_r($_POST); to see what exactly is inside your array.
hollsk
@hollsk: That's not entirely true. `isset()` returns true if the variable is set *and* it is *not* null. If you set it to `null`, it will still be "unset" as far as `isset()` is concerned.
Daniel Egeberg
Yes, you're quite correct, of course - the whole empty != null thing can be a slippery beast for an imperfect human mind sometimes :-)
hollsk
A: 

What's your error message?

Anyway, you should change if(isset($_POST['passwd'])) { to if(empty($_POST['passwd'])) { and add a } to that.

Marwelln
The error messages are $login_p_error and $login_domain_errorDoes not work though....
Jean