isset() function is returning true even when item is not set

后端 未结 4 681
独厮守ぢ
独厮守ぢ 2020-12-04 02:42

Here is my code. For some reason, if I submit the form without placing and passwords in, it still creates the database entry. There are some comments scattered throughout th

4条回答
  •  时光取名叫无心
    2020-12-04 03:17

    simple solution: if(!empty($_POST['xxx']) == true) almost equals when you use:

    if(isset($_POST['xxx']) == true && $_POST['xxx'] != '')
    

    except: isset() regards 0(string or number) as true, while empty() regards 0 as true.

提交回复
热议问题