Php 数据库中出现的空白数据,没有用户注册
我有一个用户注册表单,它接受数据并将其保存在数据库中,但有时在数据库中会保存一条空记录。为什么会有这个问题 我的代码如下。 Html文本框和以下代码位于index.php文件中Php 数据库中出现的空白数据,没有用户注册,php,Php,我有一个用户注册表单,它接受数据并将其保存在数据库中,但有时在数据库中会保存一条空记录。为什么会有这个问题 我的代码如下。 Html文本框和以下代码位于index.php文件中 if(isset($_POST[btnSubmit])) { if( !empty($txtName) && !empty($txtEmail) && !is_numeric($txtEmail) ) { //data saving code
if(isset($_POST[btnSubmit]))
{
if( !empty($txtName) && !empty($txtEmail) && !is_numeric($txtEmail) )
{
//data saving code goes here......
}
}
PHP5.5
if( !empty(trim($txtName)) && !empty(trim($txtEmail)) && !is_numeric($txtEmail) )
{
//data saving code goes here......
}
$txtName = trim($txtName);
$txtEmail = trim($txtEmail);
if( !empty($txtName) && !empty($txtEmail) && !is_numeric($txtEmail) )
{
//data saving code goes here......
}
您是否遗漏了btnSubmit的报价
$\u POST['btnSubmit']
请提供更多信息。它什么时候保存空记录?当您提交空字段时,$\u POST['btnSubmit']不需要设置?变量在哪里初始化?首先为空
,然后修剪
!难以置信的三名投票人和一名回答者没有费心实际检查此代码: