$ _POST错误输出它总是告诉我不是空的,即使字段是空白的 [英] $_POST wrong output it always tell me not empty even though fields are blank

查看:67
本文介绍了$ _POST错误输出它总是告诉我不是空的,即使字段是空白的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么每次单击注册提交按钮时输出始终为非空!即使我没有输入任何东西。我想要的是当我输入一些东西时它会告诉我不是空的,当没有任何角色时它会告诉我空。



希望有人可以开悟我在这个问题上。提前谢谢。



我的尝试:



< ; html>

< body>

< form action =method =post>

< fieldset>

< legend>用户注册< / legend>

< label for =username>用户名:< / label>

< input type =textid =usernamename =usernamevalue =autocomplete =off/>< br />

< label for = 密码>选择密码:< / label>

< input type =passwordid =passwordname =passwordvalue =/>< br / >

< label for =re-password>重新输入密码:< / label>

< input type =passwordid =re -passwordname =re-passwordvalue =/>< br />

< label for =nickname> Desired Nickna我:< / label>

< input type =textid =nicknamename =nicknamevalue =/>< br />



< input type =submitid =submitvalue =REGISTER/>< br />



< / fieldset>

< / form>



< / body>

< / html>





if($ _ POST)

{

echo empty($ _ POST)? 空的! :不空!;

}

Why every time I click register submit button the output is always "not empty!" even though I did not type anything. What i want is when I type something it will tell me not empty and when there is no any character it will tell me "empty".

Hope someone can enlightened me on this matter. Thank you in advance.

What I have tried:

<html>
<body>
<form action="" method="post">
<fieldset>
<legend>User Registration </legend>
<label for="username" >Username:</label>
<input type="text" id="username" name="username" value="" autocomplete="off"/><br />
<label for="password" >Choose Password:</label>
<input type="password" id="password" name="password" value="" /><br />
<label for="re-password">Retype Password:</label>
<input type="password" id="re-password" name="re-password" value="" /><br />
<label for="nickname" >Desired Nickname:</label>
<input type="text" id="nickname" name="nickname" value="" /><br />

<input type="submit" id="submit" value="REGISTER"/><br />

</fieldset>
</form>

</body>
</html>


if($_POST)
{
echo empty($_POST) ? "empty!" : "not empty!";
}

推荐答案

_POST)

{

echo empty(
_POST)
{
echo empty(


_POST)? 空的! :不空!;

}
_POST) ? "empty!" : "not empty!";
}


那是因为
That is because the


这篇关于$ _POST错误输出它总是告诉我不是空的,即使字段是空白的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆