在没有用户注册的情况下,数据库中出现空白数据


blank data appearing in the database without user registration

我有一个用户注册表单,它接受数据并将其保存在数据库中,但有时在数据库中保存一个空记录。为什么会有这个问题?

我的代码如下。Html文本框和以下代码位于index.php文件

if(isset($_POST[btnSubmit]))
{
    if( !empty($txtName) && !empty($txtEmail) && !is_numeric($txtEmail) ) 
    {
               //data saving code goes here......
    }
}

php 5.5

if( !empty(trim($txtName)) && !empty(trim($txtEmail)) && !is_numeric($txtEmail) ) 
        {
                   //data saving code goes here......
        }

& lt;php.5.4

$txtName = trim($txtName);
$txtEmail = trim($txtEmail);
if( !empty($txtName) && !empty($txtEmail) && !is_numeric($txtEmail) ) 
        {
                   //data saving code goes here......
        }