检查输入是否不为空且存在 - PHP
Check if input is not empty and exist - PHP
我需要检查几个标签是否 "not empty"。为此,我使用:
<input id="designation" type="text" size="12" disabled="disabled" />
然后,我需要将几个<input ...>
放在一个table中。所有这些都是在 HTML 中创建的。我需要检查是否有任何标签为空。
$erreurs = array();
// Check if the tag is not empty
if((empty($_POST['CodetERDF']))) {
$erreurs[] = 'Veuillez renseigner le codet ERDF.';
echo 'Veuillez renseigner le codet ERDF.';
}`
但我的代码似乎不起作用,我不明白为什么。
禁用的输入不会发布到服务器,因此它们永远不会出现在 $_POST
中。
这同样适用于没有 name
属性的输入,因为 name
属性定义了它们在 $_POST
.
中键入的内容
备选方案是 readonly
、hidden
或简单地在会话变量中设置值/将其保存在服务器上。
我需要检查几个标签是否 "not empty"。为此,我使用:
<input id="designation" type="text" size="12" disabled="disabled" />
然后,我需要将几个<input ...>
放在一个table中。所有这些都是在 HTML 中创建的。我需要检查是否有任何标签为空。
$erreurs = array();
// Check if the tag is not empty
if((empty($_POST['CodetERDF']))) {
$erreurs[] = 'Veuillez renseigner le codet ERDF.';
echo 'Veuillez renseigner le codet ERDF.';
}`
但我的代码似乎不起作用,我不明白为什么。
禁用的输入不会发布到服务器,因此它们永远不会出现在 $_POST
中。
这同样适用于没有 name
属性的输入,因为 name
属性定义了它们在 $_POST
.
备选方案是 readonly
、hidden
或简单地在会话变量中设置值/将其保存在服务器上。