doudu8291 2013-01-20 20:04
浏览 5

使用我的PHP,我试图检查页面加载,如果用户点击提交(到达那里)或只是加载页面,但如果他们刚刚加载我得到一个错误[关闭]

I'm checking it with if ($_POST["submit"]) but of course if they didn't, it's trying to access a variable that doesn't exist. However, I was using this check to see if it did exist in the first place, but PHP outputs the error for me.

Is that... okay? I'm not doing anything with it, I'm just checking if it's there. Or is there a better way to do it?

Same thing with my radio buttons. If they hit submit I check to see their values, but if they hit submit without pressing any I get an error.

  • 写回答

2条回答 默认 最新

  • dongpin3794 2013-01-20 20:05
    关注

    You'll want to use isset for that:

    if ( isset($_POST["submit"]) )
    

    A better way would be to just check the REQUEST_METHOD, to see if it's a POST request:

    if ( $_SERVER['REQUEST_METHOD') == 'POST' )
    
    评论

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源