未定义的偏移错误 [英] Undefined offset error
本文介绍了未定义的偏移错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我根据条件显示消息在我的表单中创建了两个按钮,但它给出了错误。
如果我点击press1(按钮)它不会返回错误
如果我点击Press2(按钮)它会返回错误。但我为此写了相同的代码
我可以知道我出错了吗?
我的代码是在php
hi all,
Im creating two buttons in my form based on condition displaying message but it's giving error.
If I click press1(button) it's not return error
If I click Press2(button) it's return error. but Im write same code for this
can I know were I went wrong?
my code is in php
<?php
if($_POST['1'])
{
print "You have press 1";
}
else if($_POST['2'])
{
print "You have press 2";
}
?>
in html
in html
<form method="post" action="<?php echo $_SERVER["PHP_SELF"]; ?>">
<input type="submit" value="Press 1" name="1" />
<input type="submit" value="Press 2" name="2" />
</form>
推荐答案
_POST [' 1'])
{
print 按下1;
}
else if(
_POST['1']) { print "You have press 1"; } else if(
_POST [' 2'])
{
print 你有按2;
}
?>
_POST['2']) { print "You have press 2"; } ?>
in html
in html
<form method="post" action="<?php echo
_SERVER [ < span class =code-attribute> PHP_SELF]; ? > 跨度>>
< 输入 < span class =code-attribute> type = submit value = 按1 名称 = 1 / >
< 输入 < span class =code-attribute> type = submit value = 按2 名称 = 2 / >
< / form >
_SERVER["PHP_SELF"]; ?>"> <input type="submit" value="Press 1" name="1" /> <input type="submit" value="Press 2" name="2" /> </form>
这篇关于未定义的偏移错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文